install
npm install --global
Installs a package into the global prefix so its bin scripts are on your PATH system-wide. Global installs live outside any project's node_modules.
npm install --global <pkg>[@<version>] [<pkg>...] Common flags
| Flag | Purpose |
|---|---|
| --global (-g) | Install into the global prefix |
| --prefix <path> | Override the install location |
| --force | Overwrite existing global binaries |
| --no-fund | Suppress funding messages during install |
Examples
npm install -g pnpm Install the pnpm CLI globally
npm install -g typescript@5 Pin a specific major of tsc globally
npm ls -g --depth=0 List currently installed global packages
Gotcha
On macOS/Linux you may hit EACCES if the prefix is owned by root — use a Node version manager (nvm, fnm, volta) rather than sudo. For project tooling prefer `npx
Related commands
npm install
Installs a package (and its dependencies), adding it to package.json and refreshing package-lock.json. Without arguments, installs everything already declared in the current project's package.json.
npm exec (npx)
Runs a package's binary from a local install, the cache, or on-the-fly from the registry without a global install. `npx` is the shell-friendly shim; both are equivalent in npm 10+.
npm list
Prints the installed dependency tree of the current project (or globally). Aliases: `ls`, `la`, `ll`.
npm ci
Performs a clean, deterministic install straight from package-lock.json (or npm-shrinkwrap.json) intended for CI environments. It deletes any existing node_modules and refuses to run if package.json and the lockfile are out of sync.
npm uninstall
Removes a package from node_modules and drops it from the matching section of package.json and the lockfile. Aliases: `remove`, `rm`, `r`, `un`.