npm (software)

From Wikipedia, the free encyclopedia

npm
Npm-logo.svg
Original author(s)Isaac Z. Schlueter.
Developer(s)npm, Inc. (a subsidiary of GitHub,[1] a subsidiary of Microsoft)
Initial release12 January 2010; 12 years ago (2010-01-12)[2]
Stable release
8.3.0[3] Edit this on Wikidata / 9 December 2021; 44 days ago (9 December 2021)
Repository
Written inJavaScript
PlatformCross-platform
TypePackage manager
LicenseArtistic License 2.0
Websitewww.npmjs.com

npm[4] is a package manager for the JavaScript programming language maintained by npm, Inc.

npm is the default package manager for the JavaScript runtime 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.

Acronym[]

Contrary to popular belief, npm is not in fact an acronym for "Node Package Manager". The precursor to npm was actually a bash utility named "pm", which was the shortform name of "pkgmakeinst" - a bash function that installed various things on various platforms. If npm were to ever have been considered an acronym, it would be as "node pm" or, potentially "new pm".[5]

History[]

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).[6]

Notable breakages[]

  • In March 2016, npm attracted press attention[7] after a package called left-pad, which many popular JavaScript packages depended on, was unpublished as the result of a naming dispute between Azer Koçulu, a self-taught software engineer, and Kik.[8][9] Although the package was republished three hours later,[10] it caused widespread disruption, leading npm to change its policies regarding unpublishing to prevent a similar event in the future.[11]
  • 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.[12]
  • In July 2018, the npm credentials of a maintainer of the popular eslint-scope package were compromised resulting in a malicious release of eslint-scope, version 3.7.2. The malicious code copied the npm credentials of the machine running eslint-scope and uploaded them to the attacker.[13]
  • 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, called flatmap-stream, contained an encrypted payload that stole bitcoins from certain applications. npm administrators removed the offending package.[14][15]
  • In April 2020, a small package called is-promise resulted in outage in serverless applications and deployments worldwide by virtue of being a dependency of many big and important applications.[16]
  • In January 2022, the maintainer of the popular package colors pushed changes printing garbage text in an infinite loop. The maintainer also cleared the repository of another popular package, faker, and its package on npm, and replaced it with a README that read, "What really happened to Aaron Swartz?"[17]

Description[]

npm is included as a recommended feature in the Node.js installer.[18] 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 in the registry.[19] Packages in the registry are in CommonJS format and include a metadata file in JSON format.[20] Over 1.3 million packages are available in the main npm registry.[21] The registry does not have any vetting process for submission, which means that packages found there can potentially be low quality, insecure, or malicious.[20] Instead, npm relies on user reports to take down packages if they violate policies by being low quality, insecure, or malicious.[22] npm exposes statistics including number of downloads and number of depending packages to assist developers in judging the quality of packages.[23]

In npm version 6, the audit feature was introduced to help developers identify and fix security vulnerabilities in installed packages.[24] 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.[25]

Usage[]

npm can manage packages that are local dependencies of a particular project, as well as globally-installed JavaScript tools.[26] 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.[27] 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.[28] npm also provides version-bumping tools for developers to tag their packages with a particular version.[29] npm also provides the package-lock.json[30] file which has the entry of the exact version used by the project after evaluating semantic versioning in package.json.

Alternatives[]

There are a number of open-source alternatives to npm for installing modular JavaScript, including ied, pnpm, npmd, and Yarn, the last of which was released by Facebook in October 2016.[31] 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.[32]

At JSConf 2019 npm's former CTO announced a new federated package registry, Entropic, which is aimed at decentralisation of JavaScript commons.[33]

Registry[]

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

See also[]

References[]

  1. ^ "Microsoft-owned GitHub to acquire JavaScript package manager Npm". GeekWire. 17 March 2020.
  2. ^ "Earliest releases of npm". GitHub. Retrieved 5 January 2019.
  3. ^ https://github.com/npm/cli/releases/tag/v8.3.0; publication date: 9 December 2021; retrieved: 11 December 2021.
  4. ^ "Initial drop. Ugly, sketchy, and not even yet quite a "work in progr… · npm/cli@4626dfa". GitHub.
  5. ^ Clarke, Darcy (12 February 2021). "npm - a JavaScript package manager". GitHub. npm. Retrieved 5 October 2021.
  6. ^ Schlueter, Isaac Z. (25 March 2013). "Forget CommonJS. It's dead. **We are server side JavaScript.**". GitHub.
  7. ^ Yegulalp, Serdar (23 March 2016). "How one yanked JavaScript package wreaked havoc". InfoWorld. Retrieved 22 July 2016.
  8. ^ Williams, Chris. "How one developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript". The Register. Retrieved 17 April 2016.
  9. ^ Collins, Keith. "How one programmer broke the internet by deleting a tiny piece of code". Quartz. Retrieved 23 December 2020.
  10. ^ "kik, left-pad, and npm". Retrieved 9 May 2017.
  11. ^ "changes to unpublish policy". Retrieved 9 May 2017.
  12. ^ "Critical Linux filesystem permissions are being changed by latest version". GitHub. Retrieved 25 February 2018.
  13. ^ "Virus in eslint-scope? · Issue #39 · eslint/eslint-scope". GitHub.
  14. ^ "Details about the event-stream incident". The npm Blog. Retrieved 28 November 2018.
  15. ^ "Backdoored dependency? flatmap-stream-0.1.1 and flatmap-stream-0.1.2". Github. Retrieved 28 November 2018.
  16. ^ "ERR_INVALID_PACKAGE_TARGET". Github. Retrieved 22 August 2020.
  17. ^ "Dev corrupts NPM libs 'colors' and 'faker' breaking thousands of apps". Bleeping Computer. Retrieved 9 January 2022.
  18. ^ Dierx, Peter (30 March 2016). "A Beginner's Guide to npm – the Node Package Manager". sitepoint. Retrieved 22 July 2016.
  19. ^ Ampersand.js. "Ampersand.js – Learn". ampersandjs.com. Retrieved 22 July 2016.
  20. ^ a b Ojamaa, Andres; Duuna, Karl (2012). "Assessing the Security of Node.js Platform". 2012 International Conference for Internet Technology and Secured Transactions. IEEE. ISBN 978-1-4673-5325-0. Retrieved 22 July 2016.
  21. ^ Nassri, Ahmad (14 April 2020). "So long, and thanks for all the packages!". The npm Blog. Retrieved 6 January 2021.{{cite web}}: CS1 maint: url-status (link)
  22. ^ "npm Code of Conduct: acceptable package content". Retrieved 9 May 2017.
  23. ^ Vorbach, Paul. "npm-stat: download statistics for NPM packages". npm-stat.com.
  24. ^ npm. "'npm audit': identify and fix insecure dependencies". The npm Blog. Retrieved 14 August 2018.
  25. ^ npm. "The Node Security Platform service is shutting down 9/30". The npm Blog. Retrieved 14 August 2018.
  26. ^ Ellingwood, Justin. "How To Use npm to Manage Node.js Packages on a Linux Server". DigitalOcean. Retrieved 22 October 2016.
  27. ^ "npm-install". docs.npmjs. Retrieved 22 October 2016.
  28. ^ "semver". docs.npmjs. Retrieved 22 October 2016.
  29. ^ "npm-version". docs.npm. Retrieved 29 October 2016.
  30. ^ Koirala, Shivprasad (21 August 2017). "What is the need of package-lock.json in Node?". codeproject.
  31. ^ "Hello, Yarn!". The npm Blog. 11 October 2016. Retrieved 17 December 2016.
  32. ^ Katz, Yehuda (11 October 2016). "Why I'm working on Yarn". Retrieved 17 December 2016.
  33. ^ JSConf (3 June 2019), The economics of open source by C J Silverio | JSConf EU 2019, retrieved 3 June 2019
  34. ^ "registry | npm Docs". docs.npmjs.com. Retrieved 10 May 2021.

External links[]

Retrieved from ""