DEV Community

5hfT
5hfT

Posted on

4

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": [
            "<node_internals>/**"
        ],
        "program": "${workspaceFolder}/app.js",
        "restart": true,
        "runtimeExecutable": "nodemon"
    }
]
Enter fullscreen mode Exit fullscreen mode

5.save

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

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay