NPM Node Package Manager is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript run time environment Node.js. 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.
npm is written entirely in JavaScript and 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).
Notable breakages:
- In March 2016, npm attracted press attention after a package called
left-pad
, which was a dependency of many popular JavaScript packages, was unpublished as the result of a naming dispute. Although the package was republished 3 hours later, it caused widespread disruption, leading npm to change its policies regarding unpublishing to prevent a similar event in the future. - In February 2018, an issue was discovered in version 5.7.0 in which running
sudo npm
on Linux systems would change the ownership of system files, permanently breaking the operating system. - In July 2018, the npm credentials of a maintainer of the popular
eslint-scope
package were compromised resulting in a malicious release ofeslint-scope
, version 3.7.2. The malicious code copies the npm credentials of the machine runningeslint-scope
and uploads them to the attacker. - 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
event-stream
. The malicious package, calledflatmap-stream
, contained an encrypted payload that steals bitcoins from certain applications. npm administrators responded by removing the offending package.
npm is included as a recommended feature in Node.js installer. npm consists of a command line client that interacts with a remote registry. It allows users to consume and distribute JavaScript modules that are available on the registry. Packages on the registry are in CommonJS format and include a metadata file in JSON format. Over 477,000 packages are available on the main npm registry. The registry has no vetting process for submission, which means that packages found there can 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.
In npm version 6, the audit feature was introduced to help developers identify and fix vulnerability and security issues in installed packages. The source of security issues were taken from reports found on the Node Security Platform (NSP), and has been integrated with npm since npm’s acquisition of NSP.
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 package.json
file. In the package.json
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 package-lock.json
file which has the entry of the exact version used by the project after evaluating semantic versioning in package.json
.
The above is a brief about Node Package Manager. Watch this space for more updates in the latest trends in Technology.