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 ` or a devDependency + npm script over a global install so versions stay reproducible.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM