Install packages from the npm registry and run package.json scripts.
Synopsis
npm install [<pkg>[@<spec>] ...]
Description
A SLICC implementation of the core npm workflow: install packages into node_modules, record them in package.json, and run package.json scripts. Supports local (project) and global (-g, shared across the runtime) installs.
Options
install [<pkg>...] With no args, reads cwd package.json and installs every dependency and devDependency.
install -g <pkg> Install into /shared/lib/node_modules and publish CLI bins to /shared/bin (on $PATH).
uninstall [-g] <pkg> Remove a package and reconcile node_modules.
run [<script>] [-- <args>...] Run a package.json script; with no script name, lists available scripts.
test | start | stop | restart Shortcuts for 'npm run <name>'; a missing start falls back to 'node server.js'.
list [-g] List direct dependencies (local or global).
root [-g] Print the node_modules path (local or global).
-g, --global Operate on the shared global prefix (/shared/lib).
--silent, -s Do not echo the script banner.
--if-present Exit 0 instead of failing on a missing script.
-h, --help Show this help message.
Examples
$ npm install express
Install express into the local node_modules.
$ npm install -g typescript
Install tsc globally, available on $PATH afterward.
$ npm run build
Run the 'build' script from the nearest package.json.
$ npm run test -- --watch
Pass extra arguments through to a script.
Notes
Version specs support exact (@1.2.3), caret (@^1.2.3), tilde (@~1.2.3), @latest and @* forms, plus scoped packages (@scope/name). Installs are idempotent; re-installing an already-satisfied dependency is a no-op.
See Also
npx, i, uv, node