#0 : nth-check

JoonSimJoon·2022년 7월 2일
2

삽질기록

목록 보기
1/1
post-thumbnail

아.....

때는 2022년 어느 여름날... cra로 프로젝트를 생성하고 Happy Hacking을 기다리고 있었는데 cra가 끝나자마자 오류가 났다...

# npm audit report

nth-check  <2.0.1
Severity: high
Inefficient Regular Expression Complexity in nth-check - https://github.com/advisories/GHSA-rp65-9cf3-cjxr
fix available via `npm audit fix --force`
Will install react-scripts@2.1.3, which is a breaking change
node_modules/svgo/node_modules/nth-check
  css-select  <=3.1.0
  Depends on vulnerable versions of nth-check
  node_modules/svgo/node_modules/css-select
    svgo  1.0.0 - 1.3.2
    Depends on vulnerable versions of css-select
    node_modules/svgo
      @svgr/plugin-svgo  <=5.5.0
      Depends on vulnerable versions of svgo
      node_modules/@svgr/plugin-svgo
        @svgr/webpack  4.0.0 - 5.5.0
        Depends on vulnerable versions of @svgr/plugin-svgo
        node_modules/@svgr/webpack
          react-scripts  >=2.1.4
          Depends on vulnerable versions of @svgr/webpack
          node_modules/react-scripts

6 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

이런 내용인데 핵심은 nth-check<2.0.1만 보면된다.

아..?

근데 말이 안되는게 cra만 했는데 vulnerabilities 오류가 뜬다는거다. 아니 빌드도 안했는데???
그래서 구글링을 해보니 아주 친절하신 분께서 정리를 해주셨다. 옆에 이슈링크 남긴다. github_issue

아!!

해결법은 다음과 같다. package.json을 살짝만 수정해주면 되는데

"dependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3"
  }

dependencies에 있는 react-scriptsdevDependencies로 옮겨주면 된다. 당연한 말이지만 없으면 만들면 된다.

 "dependencies": {
   "react": "^17.0.2",
   "react-dom": "^17.0.2"
 },
 "devDependencies": {
   "react-scripts": "4.0.3"
 },

요로코롬 바꿔주자.
그리고 npm audit을 해주면... 아직도 오류가 있다.
놀랍게도 이게 정상이다. 이제 npm audit이 아닌 npm audit --production을 사용해줘야 하며, --prodoction 옵션으로 확인하면 오류가 없다.

+야 근데

근데 이러면 고질적인 문제가 해결 안된거고 그냥 제외한거 아님? 이라 할 수도 있는데 문제가 해결된게 맞다.
위 깃헙 링크에서도 자세히 설명해주셨는데, CTA는 빌드 도구라서 node application을 생성하는게 아니라 상관 없다!
자세한 설명은 깃헙이슈 보고 공부하면 될거 같다.
다들 즐코딩!

profile
안녕하세요 :)

0개의 댓글