Quick start node

  1. Create Empty folder on desktop

  2. Open with VScode and open terminal

  3. Use the following commands

Create node

npm init -y

install dependencies

npm i express nodemon 
  1. Make changes to the package.json file. Like if you are using nodemon, add what is missing under the scripts dictionary

"scripts": {
 "test": "echo "Error: no test specified" && exit 1"
 "start": "node index.js", 
 "dev": "nodemon index.js",
  1. Make a file name index.js (this is your main server with node)

const express = require('express'); 
const app = express(); 
const port = process.env.PORT || 3000;
app.listen(port, () => {
               console.log(Server running on http://localhost:${port}); 
});
  1. start node

npm run start 

or

npm run dev  

Last updated