npm (JavaScript)

npm (Node Package Manager) is the tool and registry for installing and managing reusable JavaScript packages. It comes bundled with Node.js.

JavaScript

Running npm install <package> downloads a library and records it in package.json, so anyone can recreate the project's dependencies. Installed code lives in node_modules.

npm also runs project scripts (npm run build) and is the largest software registry in the world.

Syntax

npm install <package-name>

Examples

JavaScript

// In a terminal:
// npm install lodash

import _ from "lodash";
console.log(_.chunk([1, 2, 3, 4], 2));

Output:

[ [ 1, 2 ], [ 3, 4 ] ]

See also

Back to the Dictionary