Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Hour 2. npm (Node Package Manager) > Specifying Dependencies with package.json

Specifying Dependencies with package.json

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:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial