Node.js / / 2020. 11. 5. 09:52

express.js 설치

728x90

Express.js는 node.js를 사용하기 편하게 해주는 프레임워크입니다.

 

https://expressjs.com/


npm init

npm install express --save

임시인 경우에는

npm install express no --save


한번 실행해보기

index.js

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))


node index.js를 하거나


package.json에

"scripts": {

    "start" : "node index.js",

    "test": "echo \"Error: no test specified\" && exit 1"

  },


추가한 후, npm start해도 된다. 

300x250

'Node.js' 카테고리의 다른 글

[npm] package-lock.json 필요한 이유  (0) 2021.02.01
[NVM] 노드 버젼 관리  (0) 2021.02.01
윈도우에서 nvm으로 노드버젼 바꾸기  (0) 2021.01.11
[서버제작] 1. MongoDB설치  (0) 2020.11.05
1. node.js 설치  (0) 2020.11.05
  • 네이버 블로그 공유
  • 네이버 밴드 공유
  • 페이스북 공유
  • 카카오스토리 공유