본문 바로가기
  • 기록
React

[React] npx create-react-app . 에러

by juserh 2022. 4. 12.

npx create-react-app . 명령어를 입력했더니...

이런 에러 메시지가 떴다..

찾아보니

npm uninstall -g create-react-app
npm add create-react-app

위 명령어를 순서대로 입력한 후,

다시 npx crete-react-app . 하니 정상적으로 깔림!

 

인줄 알았으나....아니다..폴더 구성은 제대로 된 것 같으나...

이와 같은 에러가 떴다.

https://stackoverflow.com/questions/71835029/suddenly-react-js-can-not-execute-create-react-app-command-why-this-is-happenin

 

Suddenly react JS can not execute create-react-app command. Why this is happening and how to solve? even --force, or --legacy-pe

npx create-react-app my-app Creating a new React app in /home/zahid/my-app. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-templ...

stackoverflow.com

https://itsmycode.com/unable-to-resolve-dependency-tree-error-when-installing-npm-packages/

 

Unable to resolve dependency tree error when installing npm packages - ItsMyCode

The Unable to resolve dependency tree error when installing npm packages occurs when you install the node dependencies with the latest version of NPM(v7).

itsmycode.com

위 두 페이지에서 npm이 v7업데이트 되면서 dependency tree error가 발생되는 경우가 있다는 것을 알았다.

이를 해결하는 방법은 두가지가 있는데

 

1. 

npm config set legacy-peer-deps true

위 명령어를 입력하면 npm 최신 버전을 사용하더라도 peer dependencies가 설치되지 않는다고 한다. 따라서 이 병령어를 입력하고 본래 react 설치 명령어를 입력하면 정상적으로 실행된다.

 

2.

node_modules 폴더와 package-lock.json 파일 삭제하고

package.json 파일의 react와 react-dom버전을 17.0.0으로 바꾸어주는 것이다.

그 후에 npm install 명령어를 입력하면 react가 17버전으로 깔리고 에러가 생기지 않는다고 한다.

 

+나는 첫번째 방법으로 시도 후 정삭적으로 실행됐다!

 

'React' 카테고리의 다른 글

[React] react 18버전 ReactDOM 관련 warning  (0) 2022.05.17
[React] react-router-dom v6 업데이트 이슈  (0) 2022.04.12