Skip to content
BENIBIX Learn

npm

Development🛠️ Editors & ToolsPackages

Also known as Node Package Manager, npm registry

The tool for getting JavaScript packages. It is also the big shelf they come from.

Think of it like

Think of it like the biggest toy shop in the world. Almost any part you want for a JavaScript app is on a shelf there.

Example

Jack runs npm install in a new React project. A folder fills up with each package the app needs.

Why it matters

Most JavaScript projects are set up and run through npm. That goes for the browser and the server.

Definition

npm is the package tool for JavaScript, and it comes with Node.js. It is also the name of the online registry where JavaScript packages are shared. It holds millions of packages, more than any other registry. The npm install command fetches packages. A file named package.json lists what a project needs. npm can also run a project's scripts, like npm test.

Example code

console
$ npm install lodash

added 1 package, and audited 2 packages in 668ms
npm fetches lodash and adds it to package.json.

Common mistake

Saving the node_modules folder in Git. It is huge, and one npm install builds it again.

Key takeaways

  1. 1
    Comes with Node. Install Node.js and you have npm.
  2. 2
    A huge registry. Millions of packages to choose from.
  3. 3
    Runs scripts too. npm test and npm run build start tasks.

Compare

Learn it properly