https://nodejs.org/ko/download
Node.js — Node.js® 다운로드
Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.
nodejs.org
원하는 Node.js 버전을 선택하여 설치한다.
node -v
npm -v
npx create-react-app [프로젝트명]
cd [프로젝트명]
npm start
Can’t resolve ‘web-vitals’ Error 조치방법
web-vitals 설치 후 재실행
npm i web-vitals --save-dev
https://code.visualstudio.com/
Visual Studio Code - Code Editing. Redefined
Visual Studio Code redefines AI-powered coding with GitHub Copilot for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows.
code.visualstudio.com
컴포넌트 파일
유틸리티 및 헬퍼 파일
상수 파일
package.json 소스
{
"name": "frontend-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^1.7.9",
"cra-template": "1.2.0",
"http-proxy-middleware": "^3.0.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.1",
"react-scripts": "5.0.1"
},
...
}
의존성은 모듈과 모듈 간의 관계를 나타내며 의존성을 관리하는 것은 유지보수나 확장성에 영향을 미치므로 소프트웨어 개발에서 매우 중요하다.
표기법 | Description |
version | 명시된 version과 일치 |
>version | 명시된 version보다 높은 버전 |
>=version | 명시된 version과 같거나 높은 버전 |
<version | 명시된 version보다 낮은 버전 |
<=version | 명시된 version과 같거나 낮은 버전 |
~version | 명시된 version과 근사한(?) 버전. 패치 버전 범위 내에서 업데이트한다. ex) ~0.0.1: 0.0.1 ≤ version < 0.1.0ex) ~0.1.1: 0.1.1 ≤ version < 0.2.0 |
^version | 명시된 version과 호환되는 버전. 마이너 버전 범위 내에서 업데이트한다. ex) ^1.0.2: 1.0.2 ≤ version < 2.0 |
package-lock.json 소스
{
"name": "frontend-react",
"version": "0.1.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "frontend-react",
"version": "0.1.0",
"dependencies": {
"axios": "^1.7.9",
"cra-template": "1.2.0",
"http-proxy-middleware": "^3.0.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.1.1",
"react-scripts": "5.0.1"
},
...
"node_modules/react-router-dom": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.1.1.tgz",
"integrity": "sha512-vSrQHWlJ5DCfyrhgo0k6zViOe9ToK8uT5XGSmnuC2R3/g261IdIMpZVqfjD6vWSXdnf5Czs4VA/V60oVR6/jnA==",
"license": "MIT",
"dependencies": {
"react-router": "7.1.1"
},
"engines": {
"node": ">=20.0.0"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
}
},
...
}
}
package-lock.json 파일이 필요한 이유
즉, package.json의 버전 범위에 따라 버전이 바뀌더라도, package-lock.json 파일이 작성된 시점의 의존성 트리가 다시 생성될 수 있도록 한다.
예시
1) Developer1이 react-router-dom을 설치함
# package.json
"react-router-dom": "^7.1.1"
# package-lock.json
"node_modules/react-router-dom": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.1.1.tgz",
"integrity": "sha512-vSrQHWlJ5DCfyrhgo0k6zViOe9ToK8uT5XGSmnuC2R3/g261IdIMpZVqfjD6vWSXdnf5Czs4VA/V60oVR6/jnA==",
"license": "MIT",
"dependencies": {
"react-router": "7.1.1"
},
"engines": {
"node": ">=20.0.0"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
}
},
2) 6개월 후 8.1.0의 새로운 버전이 나왔더라도 Developer2가 npm install을 실행하면 package-lock.json 파일에 명시된 버전의 의존성을 설치한다.
따라서, 프로젝트의 패키지 의존성이 유지된다.
프로젝트 의존성 트리 확인
npm ls
frontend-react@0.1.0 D:\xxxxx\xxxxx\frontend-react
├── axios@1.7.9
├── cra-template@1.2.0
├── http-proxy-middleware@3.0.3
├── react-dom@19.0.0
├── react-router-dom@7.1.1
├── react-scripts@5.0.1
├── react@19.0.0
└── web-vitals@4.2.4
React 프로젝트 설치를 완료하였다.
이제 BackEnd 서버와 React 서버 간에 API통신을 연결하도록 하겠다. 별도 설정을 하지 않는다면 CORS 오류가 발생할 것이다.
이전글
다음글
React axios 모듈화 (0) | 2025.02.07 |
---|---|
React-Router-Dom 정리 (0) | 2025.02.06 |
React Hook 기본 정리 / Custom Hook (1) | 2025.02.05 |
React CORS 설정 - 프록시 (http-proxy-middleware) (7) | 2025.01.31 |
React 기본 개념 정리 (5) | 2025.01.23 |
댓글 영역