JavaScript

[JavaScript] NodeJS, nodemon, babel | ํ”„๋กœ์ ํŠธ Server Setup

jjingle 2024. 3. 27. 16:11

1. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ -> VSCode ๋กœ ์‹คํ–‰

$ mkdir prjname
$ cd prjname
$ npm init -y
$ code .

 

2. git ์„ค์ •

$ git init .
$ git remote add origin gitURL
$ git push -u origin main

 

3. ๊ธฐ๋ณธ ํŒŒ์ผ ์ƒ์„ฑ

$ touch README.md
$ touch .gitignore

   

4. nodemon ์„ค์ •

$ npm i nodemon -D
// nodemon.json

{
 "exec" : "babel-node src/server.js"
}

 

5. babel ์„ค์ •

$ npm i @babel/core @babel/cli @babel/node @babel/preset-env -D

 

{
 "presets" : ["@babel/preset-env]
}

 

6. package.json  script ์ˆ˜์ •

"script" : {
	"dev" : "nodemon"  //nodemon.json ์„ค์ •ํŒŒ์ผ์„ ์ฝ์Œ
}

 

7. express, pug  ํ…œํ”Œ๋ฆฟ ์—”์ง„ ์„ค์น˜

$ npm i express
$ npm i pug

 

8. ํ”„๋กœ์ ํŠธ ์‹คํ–‰

$ npm run dev