DEV Community


Posted on

How to Start with Node JS (for Linux [debian])

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 init edit .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"
Enter fullscreen mode Exit fullscreen mode

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-dev as we have installed nodemon for develoment , it will install as devDependencies
   "devDependencies": {
         "nodemon": "^2.0.2"
Enter fullscreen mode Exit fullscreen mode

nodemon is a development tool that will automatically restart our npm start whenever we edit our code !

Debugger setting in vs code for NodeJs

  1. Go to debuger
  2. Add configuration
  3. Select node.js
  4. Edit launch.json file
"configurations": [
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
        "program": "${workspaceFolder}/app.js",
        "restart": true,
        "runtimeExecutable": "nodemon"
Enter fullscreen mode Exit fullscreen mode

Note : in the json file we just chnage the default runtimeExecutable value node to our third party package nodemon

Top comments (0)