npm

What is it?

npm (Node Package Manager) is the default package manager for Node.js and the world's largest software registry with over a million packages. It allows developers to share and reuse code packages, manage project dependencies, and run scripts. The package.json file in your project defines which packages are needed, their versions, and custom scripts.

Practical example

When starting a new project, run npm init to create a package.json file. To add a library like Axios for HTTP requests, use npm install axios which downloads it to node_modules and adds it to your dependencies. For development-only tools like testing frameworks, use npm install jest --save-dev. Run npm install on a cloned project to install all listed dependencies automatically.

Test your knowledge

What file stores npm project dependencies?

Ask Lex
Lex knows the context of this term and can give targeted explanations, examples, and extra context.
Tip: Lex replies briefly in the widget. For more detail, go to full screen mode.

Quick links