리액트 설치 전 준비
windows
Node.js 공식 홈페이지에서 LTS 다운로드
Node.js
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
* Node.js를 사용하는 이유
Node.js + npm
웹 브라우저 환경이 아닌 곳에서도 자바스크립트를 사용할 수 있도록 하는 자바스크립트 런타임임.
Node.js 패키지 매니저 도구인 npm이 함께 설치되어 패키지를 설치하고 버전관리가 가능함.
macOS
nvm을 이용하여 설치한다. (버전 업데이트와 버전 관리에 용이하다.)
Node.js 홈페이지에서 다운 받아도 상관없다.
1. Visual Studio Code 터미널에서 명령어를 실행한다.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
2. 터미널을 재시작하여 nvm 설치 확인
$ nvm --version
3. nvm 설치 확인 후 Node.js LTS 설치
$ nvm install --lts
※ 안 될 경우 참고
※ npm이 아니라 yarn을 이용해서도 리액트 프로젝트 생성 가능
Git 설치
깃 공식 홈페이지에서 다운로드
git bash 에뮬레이터를 사용하므로 깃 설치 및 세팅이 필요합니다.
Git - Downloads
Downloads macOS Windows Linux/Unix Older releases are available and the Git source repository is on GitHub. GUI Clients Git comes with built-in GUI tools (git-gui, gitk), but there are several third-party tools for users looking for a platform-specific exp
git-scm.com
리액트 프로젝트 생성하기
npm으로 작업환경 구축
1. VS code 터미널을 열어 bash 창으로 변경 후에 명령어 입력한다.
$ npm init react-app my-project
아래 더보기와 같은 내용이 나오면 설치중 입니다.
$ npm init react-app my-project
Creating a new React app in D:\me\collieLog\test\npm-init-react-app\my-project.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
added 1392 packages in 56s
203 packages are looking for funding
run `npm fund` for details
Initialized a git repository.
Installing template dependencies using npm...
added 52 packages in 3s
203 packages are looking for funding
run `npm fund` for details
Removing template package using npm...
removed 1 package, and audited 1444 packages in 2s
203 packages are looking for funding
run `npm fund` for details
6 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
Created git commit.
Success! Created my-project at D:\me\collieLog\test\npm-init-react-app\my-project
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd my-project
npm start
2. 프로젝트 생성 완료 확인 후 다음 명령어 입력한다.
$ cd my-project
$ npm start
위와 같은 화면이 나타나면 프로젝트 생성에 성공한 것 입니다.
리액트 페이지가 자동으로 띄워진 브라우저를 확인해보세요.
- 화면이 자동으로 띄워지지 않은 경우 http://localhost:3000/ 입력.
- VS code 종료 후 다시 열었을 때, 리액트 작업 화면 불러오려면 터미널에 $ npm start 입력.
* 잘못된 정보 및 오류가 있을 경우 댓글에 적극적으로 말씀 부탁드립니다. 수정, 보완 하겠습니다.
'React' 카테고리의 다른 글
[리액트] Function vs Class(Component) 클래스형 컴포넌트와 함수형 컴포넌트의 차이 (0) | 2022.07.22 |
---|---|
[리액트] 폼으로 전송한 속성 위치 확인하는 법(debugger) (0) | 2022.07.20 |
[리액트] JSX 리액트 문법 소개, 리액트 코드 이해 (0) | 2022.07.17 |
[리액트] 주석 작성 방법 (0) | 2022.07.16 |
[리액트] 리액트란? / 리액트 장점 단점 (0) | 2022.07.14 |