본문 바로가기
IT/JavaScript와 Framework

express 프로젝트 만들기

by 골든크랩 2021. 6. 16.
728x90
반응형

1. expres-first 디렉토리 생성

 

2. 프로젝트 파일 생성

~/Projects/NodeJS/express-first$ npm init -y
Wrote to /home/mhchae3/Projects/NodeJS/express-first/package.json:

 

package.json 파일이 생성되는데, 패키지 의존성 관리를 한다.

 

3.  app.js 파일 생성. 보통 진입점으로 잡음.

const express = require('express')

 

4.  app.js 파일 생성. 보통 진입점으로 잡음.

 

5. 레포지토리 검색

-> npmjs 사이트에서 검색 가능함

https://www.npmjs.com/

5. express 설치

~/Projects/NodeJS/express-first$ npm i express
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN express-first@1.0.0 No description
npm WARN express-first@1.0.0 No repository field.

+ express@4.17.1
added 50 packages from 37 contributors and audited 50 packages in 3.933s
found 0 vulnerabilities

 

6. node_modules 디렉토리가 추가된것을 확인할 수 있다.

~/Projects/NodeJS/express-first$ ls -l
합계 28
-rw-rw-r--  1 mhchae3 mhchae3    37  6월 16 15:32 app.js
drwxr-xr-x 52 mhchae3 mhchae3  4096  6월 16 15:38 node_modules
-rw-r--r--  1 mhchae3 mhchae3 14350  6월 16 15:38 package-lock.json
-rw-r--r--  1 mhchae3 mhchae3   277  6월 16 15:38 package.json

 

7. package-lock.json 파일도 생긴다. 수정하면 안되는 파일.

~/Projects/NodeJS/express-first$ ls -l
합계 28
-rw-rw-r--  1 mhchae3 mhchae3    37  6월 16 15:32 app.js
drwxr-xr-x 52 mhchae3 mhchae3  4096  6월 16 15:38 node_modules
-rw-r--r--  1 mhchae3 mhchae3 14350  6월 16 15:38 package-lock.json
-rw-r--r--  1 mhchae3 mhchae3   277  6월 16 15:38 package.json

 

8. package.json 파일이 자동 수정됨.  dependecies 항목이 생김

 

"dependencies": {

"express": "^4.17.1"

}

 

9. 공유시 package.json과 소스파일만 공유하면, dependecies 항목을 보고 필요한 모듈을 설치해준다.

 

 10. 시멘틱 버저닝

의미  : 버전을 3자리로 관리하는것.

https://semver.org/

 

 

 

 

728x90
반응형

댓글