Add packages to dependency in Nodejs

Do you know that, we can add package names to packages.json file while install using npm ( Node Package Manager)

Wanna learn how to add a package file to Node project. Here it is

  • Auto generate package.json file for Nodejs project

    Nodejs project is the easiest and fastest way to create web applications. A package.Json file is the configuration file for the Nodejs project, it included all the information regarding the project. The dependencies, developer dependencies, starting scripts and so on. We can manually add a package file to our project. The structure of a minimal package file will be as follows.

      "name": "Project Name",
      "version": "1.0.0",
      "description": "Description of your Project",
      "main": "app.js",
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      "author": "Developer Name",
      "license": "ISC"

    Auto generate package file

    Node Package Manager can auto generate the package file by issuing the following command on Terminal

    npm init
    •  npm will pull few question and answer them or leave it for default and then finally we will get the package.json file.


For this we have to use npm install <package-name> –save

npm install express  --save

In your package file it will show as

 "dependencies": {
        "express": "^4.17.1",
        "": "^3.0.1"

Uninstalling will also remove it from the dependency list.

Developer dependecies

Packages which are used only for at the time of development are called developer dependecies. We can add developer dependencies by adding an option with Install save option as -dev. nodemon is an ideal example for development dependency.

npm install nodemon --save-dev

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.