EXPRESS.js : Node.js 의 프레임 워크npm install express : npm 설치{
"name": "boiler-plate",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
***"start": "node index.js", -> 추가***
"test": "echo \\"Error: no test specified\\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
const express = require('express') //express 프레임 워크 추가
const app = express() //앱 객체에 지정
const port = 5000 //포트 번호 -> 로컬이어서 번호 뭐가 되든 노상관
app.get('/', (req, res) => { //-> 루트 디렉토리에 실행
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening at <http://localhost>:${port}`)
})
인터넷에 localhost:5000 쳐서 출력 확인
npm run start : vscode 터미널에 입력해서 실행
useNewUrlParser : true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false
오류방지