๋ฐ์ํ
์ฐธ๊ณ
ํ๋ก์ ํธ ์์ฑ ๋ฐ ์คํ
- ํ๋ก์ ํธ ํด๋ ์์ฑ
- package.json ํ์ผ ์์ฑ
npm init
- express ์ค์น =>node_modules ํด๋๊ฐ ์์ฑ๋จ
npm install express --save
- app.js ํ์ผ ์์ฑํ๊ธฐ (์๋ฒ ์์ ํ์ผ)
const express = require('express');
const app = express();
const port = 3000
app.get('/', (req, res) => {
res.send('Hello Express!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
- package.jsonํ์ผ ์์
script์ ์ถ๊ฐ
"start": "node {์๋ฒํ์ผ๋ช
}”
- ์คํํ๊ธฐ
npm start
๋ฐ์ํ