NPM(1)

📦 version 10.8.2, in fedora 43, fedora 44

💖 NPM(1) 💖

okay bestie, gather round, because we're about to talk about npm — the javascript package manager, and yes she's the manual page you're reading right now. this is npm(1), and she is serving.


✨ SYNOPSIS ✨

npm
⚠️ heads up bestie: this command is unaware of workspaces. like, it genuinely does not know they exist. don't ask her about them.

🌸 VERSION 🌸

10.8.2 — that's the girl. that's the one we're talking about. 💅


💜 DESCRIPTION 💜

so. npm is the package manager for the Node JavaScript platform. she puts modules in place so that node can find them, and she manages dependency conflicts intelligently — which is a fancy way of saying she keeps the drama between your packages from turning into a full group-chat meltdown. 👑

she is extremely configurable to support a whole variety of use cases. most commonly, you use her to publish, discover, install, and develop node programs. that's the whole vibe.

run npm help to get a list of available commands. it's giving menu at a really good restaurant. 🍓


🔥 IMPORTANT 🔥

okay this part is lowkey the fine print but it MATTERS so read it bestie:

npm comes preconfigured to use npm's public registry at https://registry.npmjs.org by default. use of the npm public registry is subject to terms of use available at https://docs.npmjs.com/policies/terms.

you can configure npm to use any compatible registry you like, and you can even run your own registry — main character energy, honestly. but use of someone else's registry is governed by their terms of use. not ours. theirs. so check before you go touching other people's stuff. 🙈


🦋 INTRODUCTION 🦋

you probably got npm because you want to install stuff. no shame, that's literally why she exists. ✨

the very first thing you will most likely want to run in any node program is:

npm install

...which installs its dependencies. iconic behavior.

you can also run:

npm install blerg

to install the latest version of "blerg". (yes, blerg. she's real in this household.) check out npm help install for more info — it can do a LOT of stuff, like an unreasonable amount, like she's been holding it in.

use the npm search command to show everything that's available in the public registry. use npm ls to show everything you've installed. 👀


🧚 DEPENDENCIES 🧚

if a package lists a dependency using a git URL, npm will install that dependency using the git command ⟨https://github.com/git-guides/install-git⟩ and will generate an error if it is not installed. so like, have git. please.

if one of the packages npm tries to install is a native node module and requires compiling of C++ Code, npm will use node-gyp ⟨https://github.com/nodejs/node-gyp⟩ for that task. here's the tea:

for more information visit the node-gyp repository ⟨https://github.com/nodejs/node-gyp⟩ and the node-gyp Wiki ⟨https://github.com/nodejs/node-gyp/wiki⟩. 🛠️


🎀 DIRECTORIES 🎀

see npm help folders to learn about where npm puts stuff. she's organized. she has a system. respect it.

in particular, npm has two modes of operation:

  • local mode: npm installs packages into the current project directory, which defaults to the current working directory. packages install to ./node_modules, and bins to ./node_modules/.bin.
  • global mode: npm installs packages into the install prefix at $npm_config_prefix/lib/node_modules and bins to $npm_config_prefix/bin.

local mode is the default. use -g or --global on any command to run in global mode instead. 💫


💅 DEVELOPER USAGE 💅

if you're using npm to develop and publish your code, check out the following help topics — this is the syllabus, bestie:

  • json: make a package.json file. see package.json ⟨/configuring-npm/package-json⟩.
  • link: links your current working code into Node's path, so that you don't have to reinstall every time you make a change. use npm help link to do this.
  • install: it's a good idea to install things if you don't need the symbolic link. especially, installing other peoples code from the registry is done via npm help install.
  • adduser: create an account or log in. when you do this, npm will store credentials in the user config file. 🔐
  • publish: use the npm help publish command to upload your code to the registry. go off, share your art. 🌈

⭐ CONFIGURATION ⭐

npm is extremely configurable. she reads her configuration options from 5 places. five. count 'em.

  • Command line switches: set a config with --key val. all keys take a value, even if they are booleans (the config parser doesn't know what the options are at the time of parsing). if you do not provide a value (--key) then the option is set to boolean true.
  • Environment Variables: set any config by prefixing the name in an environment variable with npm_config_. for example, export npm_config_key=val.
  • User Configs: the file at $HOME/.npmrc is an ini-formatted list of configs. if present, it is parsed. if the userconfig option is set in the cli or env, that file will be used instead.
  • Global Configs: the file found at ./etc/npmrc (relative to the global prefix will be parsed if it is found. see npm help prefix for more info on the global prefix. if the globalconfig option is set in the cli, env, or user config, then that file is parsed instead.
  • Defaults: npm's default configuration options are defined in lib/utils/config/definitions.js. these must not be changed. 🚨 like genuinely, hands off.

see npm help config for much much more information. (she said much much. she meant it.)


🫶 CONTRIBUTIONS 🫶

patches welcome! 🎉

if you would like to help, but don't know what to work on, read the contributing guidelines ⟨https://github.com/npm/cli/blob/latest/CONTRIBUTING.md⟩ and check the issues list. you belong here, bestie. 💖


😭 BUGS 😭

when you find issues, please report them: ⟨https://github.com/npm/cli/issues⟩

please be sure to follow the template and bug reporting guidelines. the template is not a suggestion, it's the blueprint. 📋


🌟 FEATURE REQUESTS 🌟

discuss new feature ideas on our discussion forum:

or suggest formal RFC proposals:

big brain ideas go here. we love a visionary. 👑


👑 SEE ALSO 👑

  • npm help help
  • package.json ⟨/configuring-npm/package-json⟩
  • npm help npmrc
  • npm help config
  • npm help install
  • npm help prefix
  • npm help publish

and that's the whole page, bestie!! 🦋 this was NPM@10.8.2, dated July 2024, and yes the manual section is NPM(1) in case you forgot where you were. slay, go install something, ily, periodt. 💖✨🎀

📦 where this page comes from