Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
As you develop Node.js applications, you will undoubtedly make use of modules. Installing each module one by one can be time consuming and prone to error. What if you forget to install a module, for example?
Thankfully, npm allows developers to specify the modules that they want to use in their application using a package.json file and then to install them with a single command:
npm install
This has many advantages:
• You do not have to install modules one by one.
• It is easy for other developers to install your application.
• Your application’s dependencies are stored in a single place.
Returning to the example where we installed the underscore module, we can now add a package.json file to the project. A package.json file just contains information about the project in a specified format. A minimal package.json looks like this: