Npm

npm is a package manager for the JavaScript programming language maintained by npm, Inc., a subsidiary of GitHub. npm is the default package manager for the JavaScript runtime environment Node.js and is included as a recommended feature in the Node.js installer.

It consists of a command line client, also called npm, and an online database of public and paid-for private packages, called the npm registry. The registry is accessed via the client, and the available packages can be browsed and searched via the npm website. The package manager and the registry are managed by npm, Inc.

Although "npm" is commonly understood to be an abbreviation of "Node Package Manager", it is officially a recursive backronym for "npm is not an acronym".

History
npm was developed by Isaac Z. Schlueter as a result of having "seen module packaging done terribly" and with inspiration from other similar projects such as PEAR (PHP) and CPAN (Perl). npm is a JavaScript replacement for pm, a shell script.

The company npm, Inc. was founded in 2014 in Oakland, California, United States, with Laurie Voss as co-founder. Bryan Bogensberger joined the company as CEO in July 2018 and resigned in September 2019. Before Bogensberger's resignation, Laurie Voss resigned in July 2019.

In March 2020, npm was acquired by GitHub, which is a subsidiary of Microsoft.

Usage
npm can manage packages that are local dependencies of a particular project, as well as globally-installed JavaScript tools. When used as a dependency manager for a local project, npm can install, in one command, all the dependencies of a project through the  file. In the  file, each dependency can specify a range of valid versions using the semantic versioning scheme, allowing developers to auto-update their packages while at the same time avoiding unwanted breaking changes. npm also provides version-bumping tools for developers to tag their packages with a particular version. npm also provides the file which has the entry of the exact version used by the project after evaluating semantic versioning in.

Client
npm's command-line interface client allows users to consume and distribute JavaScript modules that are available in the registry.

In February 2018, an issue was discovered in version 5.7.0 in which running  on Linux systems would change the ownership of system files, permanently breaking the operating system.

In npm version 6, the audit feature was introduced to help developers identify and fix security vulnerabilities in installed packages. The source of security vulnerabilities were taken from reports found on the Node Security Platform (NSP) and has been integrated with npm since npm's acquisition of NSP.

Registry
Packages in the registry are in ECMAScript Module (ESM) or CommonJS format and include a metadata file in JSON format.

Over 3.1 million packages are available in the main npm registry.

The registry does not have any vetting process for submission, which means that packages found there can potentially be low quality, insecure, or malicious. Instead, npm relies on user reports to take down packages if they violate policies by being low quality, insecure, or malicious. npm exposes statistics including number of downloads and number of depending packages to assist developers in judging the quality of packages.

Internally npm relies on the NoSQL Couch DB to manage publicly available data.

left-pad
In March 2016, a package called  was unpublished as the result of a naming dispute between Azer Koçulu, an individual software engineer, and Kik. The package was immensely popular on the platform, being depended on by thousands of projects and reaching 15 million downloads prior to its removal. Several projects critical to the JavaScript ecosystem including Babel and Webpack depended on  and were rendered unusable. Although the package was republished three hours later, it caused widespread disruption, leading npm to change its policies regarding unpublishing to prevent a similar event in the future.

peacenotwar
In March 2022, developer Brandon Nozaki Miller, maintainer of the  package, added   as a dependency to the package;   recursively overwrites an affected machine's hard drive contents with the heart emoji if they have a Belarusian or Russian IP address. The package also leaves a text file on the machine containing a message in protest of the Russian invasion of Ukraine. Vue.js, which uses  as a dependency, did not pin its dependencies to a safe version, meaning that some users of Vue.js became affected by the malicious package if the dependency was fetched as the latest package. The affected dependency was also briefly present in version 3.1 of Unity Hub; a hotfix was released the same day to remove the issue, however.

Other notable incidents
In November 2018, it was discovered that a malicious package had been added as a dependency to version 3.3.6 of the popular package. The malicious package, called, contained an encrypted payload that stole bitcoins from certain applications.

In May 2021,, an npm package that received over 3 million downloads per week, was discovered to have a remote code execution vulnerability. The vulnerability resulted from how the package handed config files, and was fixed in versions 5 and greater.

In January 2022, the maintainer of the popular package  pushed changes printing garbage text in an infinite loop. The maintainer also cleared the repository of another popular package,, and its package on npm, and replaced it with a README that read, "What really happened to Aaron Swartz?"

In May 2023, several npm packages including  were found to be exploited, stealing user credentials and information from affected machines. Researchers discovered that these packages had been compromised through an exploit involving Amazon S3 buckets and the  command line tool.

Alternatives
There are a number of open-source alternatives to npm for installing modular JavaScript, including Yarn, Bun and Deno. Deno and Bun also provide a JavaScript runtime, while only Deno operates independently from NPM Registry or any centralized repository and its support of NPM registry is still a subject of ongoing work in progress as of January 2024. They are all compatible with the public npm registry and use it by default, but provide different client-side experiences, usually focused on improving performance and determinism compared to the npm client.