mkdir node-first-project
cd node-first-project
Create project directory and move into it. This directory will be your project root directory.
npm init
if you need more information about package.json, click the link below.
ref(공식문서) - https://docs.npmjs.com/cli/v6/configuring-npm/package-json/
npm install express nodemon
Installing express and nodemon sametime.
💡 When you launch your node.js application with Nodemon it will monitor for any changes and automatically restart the server, improving your productivity.
if you check your package.json, it holds your packages that you've just installed(express, nodemon).
{
...
"dependencies":{
"express": "^4.17.1",
"nodemon": "^2.0.7"
}
🕹 Usage: npm commands
npm run <foo> run the script named <foo>
🕹 package.json: Setting up npm script
{...
"script":{
"server": "nodeman app.js"
},
...
}
app.listen(3000);
app.get('/', (req, res) => {
res.send('halo m8');
});
app.use('/', () => {
console.log('This is middleware running');
});