React/설치 및 환경 구축

[React] Create react app 사용하는 방법 & 설치 오류 해결 방법

ssddo 2021. 12. 26. 21:50

* 그동안 vscode 와 같은 에디터에서 학습하지 않고 https://codesandbox.io/s/6yoqonyo7r 에서 진행을 했었다

* 에디터 vscode로 react 환경을 구축하는 방법은 아래와 같다


필요한 도구 설치

- node js (node js를 직접적으로 사용하지는 않지만 Webpack 과 Babel을 사용하기 위해 꼭 설치함)

- yarn (추천)

choco install yarn

- vscode (에디터)

 


Create react app 사용하는 방법

* 해당 방법은 window 기준 입니다.

 

1. cmd 에서 폴더 생성 및 해당 폴더로 이동

mkdir react-tutorials
cd react-tutorials

 

2. create react app 설치 및 폴더 생성

npx create-react-app contact-app

3. 완료

- 2번까지 따라한 후에 해당 폴더를 vscode를 사용하여 열게 되면 아래와 같이 환경이 구축되는 것을 확인할 수 있음


설치 오류

위의 방법을 실행하던 도중 2번에서 오류가 생겼다

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/
최신 버전(5.0.0)보다 뒤처진 'create-react-app' 4.0.3을 실행하고 있습니다.

더 이상 Create Response App 글로벌 설치를 지원하지 않습니다.

다음 명령 중 하나를 사용하여 글로벌 설치를 제거하십시오.
- npm 제거 -g 생성-응용 프로그램
- yarn 전역 제거 생성-제거-앱

새 앱을 만드는 최신 지침은 다음에서 확인할 수 있습니다.
https://create-create-application.dev/dev/getting-creating-app/

이런 오류인데 cmd에 npm uninstall -g create-react-app 또는 yarn global remove create-react-app을 실행하였다

그리고 다시 2번을 실행한 후에

y 를 입력해주면 해결된다