package.json
"start":"node app.js" ๋ก ์ค์ ํด์ฃผ์ด
npm start๋ง ํด๋ ์ฑ์ด ๊ตฌ๋๋จ์ ์๋ ค์ค + ์์์ js๊ฐ ๋ฌด์์ธ์ง ์๋ ค์ค ์ ์์
{
"name": "node-test",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"node app.js"
},
"author": "",
"license": "ISC"
}
"start-server":"node app.js" ์์ผ๋ก ๋ช ๋ช ํ๋ ๊ฒ์ ๊ฐ๋ฅํ๋ฐ
start๋ ํน์ํ ๋ช ๋ น์ด์ด๊ณ
start-server๋ ์ฌ์ฉ์ ์ ์ ๋ช ๋ น์ด์ด๋ฏ๋ก
npm run start-server ์์ผ๋ก run์ ๊ผญ ์ถ๊ฐํด์ฃผ์ด์ผ ํจ
Nodemon
์ฝ๋๊ณ ์น๊ณ ์๋ฒ ๋๊ณ ์ฌ์์,
์ฝ๋๊ณ ์น๊ณ ๋ ์๋ฒ ๋๊ณ ์ฌ์์... ๋๋ฌด ๊ท์ฐฎ๊ธฐ ๋๋ฌธ์
์ ์ฅ ํ ์๋ฒ ์๋ ์ฌ์์์ด ๋ ์ ์๋ค๋ฉด ์ข์ง ์๊ฒ ๋๊ฐ
์ ์ฅ ๋ฐ ์๋ฒ์๋ ์ฌ์์์ ๋ถํผ ๊ฟ์ ์๊ณ nodemon์ ์ค์นํด๋ณด์
npm install nodemon --save-dev
ํ๋ก๋์ ์์กด์ฑ vs ๊ฐ๋ฐ ์์กด์ฑ
๊ฐ๋ฐํ ๋๋ง ์ธ ๊ฒ์ด๋ฏ๋ก ๊ฐ๋ฐ ์์กด์ฑ์ผ๋ก ์ค์นํด์ฃผ์.
(npm install nodemon --save ๋ก ํ๋ฉด ํจํค์ง๊ฐ ํ๋ก๋์ ์์กด์ฑ์ผ๋ก ์ค์น๋๋ค)
(์ฐธ๊ณ ๋ก -g๋ก ์ค์น์, ํ์ฌ ์์ ์ค์ธ ํ๋ก์ ํธ ๋ฟ์๋๋ผ ๋จธ์ ๋ด์ ์๋ ๋ชจ๋ ํ๋ก์ ํธ ์ ์ฒด์ ์ ์ฉ๋จ)
๊ทธ๋ผ ์ด๋ ๊ฒ ๋ณ๊ฒฝ๋๋ค.
{
"name": "node-test",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.20"
}
}
"nodemon": "^2.0.20"
์ฌ๊ธฐ์์
^ ์ด ํ์๋ ์ด ํจํค์ง๊ฐ ์ด๋ป๊ฒ ์ ๋ฐ์ดํธ๋ ์ง๋ฅผ ์ ์
์ด๋ ๊ฒ package.json์ ์ ์๋ ๋ชจ๋๋ค์ ๋ค๋ฅธ ์ปดํจํฐ์์๋ ์ฐ๊ณ ์ถ๋ค๋ฉด
ํ๋ก์ ํธ ๊ทธ๋๋ก pull ๋ฐ์์ฃผ๊ณ
npm install
ํด์ฃผ๋ฉด ๋๋ค.
์์ง ์ค์ ์ ๋๋ฌ๋ค.
์ด์ package.json ์์
"start": "nodemon app.js" ์ด๋ ๊ฒ ๋ฐ๊ฟ์ค๋ค.
{
"name": "node-test",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.20"
}
}
์ด์ npm start๋ฅผ ํด์ฃผ๊ณ ์ฝ๋๋ฅผ ๊ณ ์ณ๋ณด์ ! (์๋ก๊ณ ์นจ ํ์)
๊ฐ๋ฐ ํธ์๊ฐ ์์๊ฐ์ ์ฌ๋ผ๊ฐ๋ค !
'Javascript > Node.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[node] express ์ค์น ํ๊ฒฝ ์กฐ์ฑํด๋ณด๊ธฐ (0) | 2022.12.18 |
---|---|
[Node.js] (7) Node ๋ชจ๋ ์์คํ ์ฌ์ฉ (0) | 2022.12.13 |
[Postman] Rest APIs ๊ฐ๋ฐ์ ์ํ ํฌ์คํธ๋งจ ์ ์ (0) | 2022.12.12 |
[Node.js] (6) Single Thread, Event Loop & Blocking Code (0) | 2022.12.09 |
[Node.js] (5) ์์ฒญ๊ณผ ์๋ต ์ฐ๊ฒฐํ๊ธฐ, ๋ฒํผ ๊ฐ๋ (๋ฆฌ๋๋ ์ , ์ ์ ์ ๋ ฅ๊ฐ ํ์ผ์์ฑ ํ ์ ์ฅ) (0) | 2022.11.24 |