Page 34 -
P. 34
따라서 초반에는 복잡하게 설정하는 부분을 모두 생략하고, 바로 리액트 프로젝트를 만들 수 있는 1
create-react-app 도구를 사용할 것입니다. 이 도구를 사용하면 프로젝트 핵심 기능들의 설정을 미
리 완료한 채 리액트 프로젝트를 만들 수 있습니다. 리액트 시작
1.3.5.1 설치
create-react-app 도구는 npm 또는 yarn으로 설치할 수 있습니다. 패키지를 설치하는 방법은 두
가지가 있는데요. 첫 번째는 지역적(local)으로 설치하는 것이고, 두 번째는 전역적(global)으로 설치
하는 것입니다. 둘의 차이는 프로젝트 디렉터리에서만 사용하느냐, 아니면 모든 디렉터리에서 사
용하느냐입니다. create-react-app은 커맨드라인 도구라 모든 디렉터리에서 필요하므로 전역적으
로 설치하겠습니다.
$ yarn global add create-react-app # 또는 npm install -g create-react-app
1.3.5.2 프로젝트 생성
프로젝트를 만들 때는 create-react-app <프로젝트 이름> 명령어를 사용합니다. 터미널을 열어서
다음 명령어를 입력하세요. 이 작업은 1~3분 정도 소요됩니다.
$ create-react-app hello-react
Creating a new React app in /Users/velopert/awesome-react/hello-react.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
(...)
Done in 24.88s.
Success! Created hello-react at /Users/velopert/awesome-react/hello-react
Inside that directory, you can run several commands:
yarn start
Starts the development server.
yarn build
Bundles the app into static files for production.
yarn test
Starts the test runner.
043
리액트를 다루는 기술(본문출력용)0720.indb 43 2018-07-20 오전 11:25:20