Open Terminal :
- Install NodeJs : - $ sudo apt install nodejs
- check version : - $ node --version
in some case you have to install npm (node package manager) manually
- npm installation : - $ sudo apt install npm
- make a json file : - npm initedit .json file and in script write your own command to run node server .
 
 
Example :
"scripts": {
    "test": "echo "Error: no test specified" && exit 1",
    "start": "node app.js",
    "start-server":"node app.js"
}
in this case npm start will start the server app.js 
Note : start is a special node command . But if we want our own command such as start-server , we have to use
npm run start-server
- update npm globally :sudo npm install -g npm
Installing 3rd party packages :
- install nodemon : npm install nodemon --save-devas we have installed nodemon for develoment , it will install as devDependencies
   "devDependencies": {
         "nodemon": "^2.0.2"
     }
nodemon is a development tool that will automatically restart our npm start whenever we edit our code !
Debugger setting in vs code for NodeJs
- Go to debuger
- Add configuration
- Select node.js
- Edit launch.json file
"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
            "<node_internals>/**"
        ],
        "program": "${workspaceFolder}/app.js",
        "restart": true,
        "runtimeExecutable": "nodemon"
    }
]
5.save
Note : in the json file we just chnage the default runtimeExecutable value node to our third party package nodemon
 

 
    
Top comments (0)