Maintaining package dependencies with npm

As we mentioned earlier, the npm install command by itself installs the packages listed in the dependencies section of package.json. This is easy and convenient. Simply by listing all the dependencies, it's quick and easy to install the dependencies required for using the package. What happens is npm looks in package.json for the dependencies or devDependencies field, and it will automatically install the mentioned packages.

You can manage the dependencies manually by editing package.json. Or you can use npm to assist you with editing the dependencies. You can add a new dependency like so:

$ npm install akasharender --save  

In response, npm will add a dependencies tag to package.json:

"dependencies": ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.