/commands/npm/npm-install-specific-version
npm install a specific version: npm install package@version
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 11.19.0updated 2026-10-20
- tool
- npm
- versions
- npm 7+
- os
- any
npm install lodash@4.17.21 installs exactly version 4.17.21 and records it in package.json. The part after @ can also be a semver range (lodash@^4.17.0) or a dist-tag (react@next, typescript@beta).
Install an exact version
npm init -y >/dev/null
npm install --no-audit --no-fund lodash@4.17.21
npm ls lodash
npm pkg get dependenciesOutput
added 1 package in 2s
work@1.0.0 /tmp/work
└── lodash@4.17.21
{
"lodash": "^4.17.21"
}By default npm writes a caret range (^4.17.21) to package.json. Add --save-exact (-E) to record exactly 4.17.21.
See which versions exist
npm view lodash@4.17 version
npm view lodash dist-tagsOutput
lodash@4.17.0 '4.17.0'
lodash@4.17.1 '4.17.1'
lodash@4.17.2 '4.17.2'
lodash@4.17.3 '4.17.3'
lodash@4.17.4 '4.17.4'
lodash@4.17.5 '4.17.5'
lodash@4.17.9 '4.17.9'
lodash@4.17.10 '4.17.10'
lodash@4.17.11 '4.17.11'
lodash@4.17.12 '4.17.12'
lodash@4.17.13 '4.17.13'
lodash@4.17.14 '4.17.14'
lodash@4.17.15 '4.17.15'
lodash@4.17.16 '4.17.16'
lodash@4.17.17 '4.17.17'
lodash@4.17.18 '4.17.18'
lodash@4.17.19 '4.17.19'
lodash@4.17.20 '4.17.20'
lodash@4.17.21 '4.17.21'
lodash@4.17.23 '4.17.23'
{ latest: '4.18.1' }Version specifiers
| Specifier | Installs |
|---|---|
| pkg@1.2.3 | exactly 1.2.3 |
| pkg@^1.2.3 | highest 1.x.x that is >= 1.2.3 |
| pkg@~1.2.3 | highest 1.2.x that is >= 1.2.3 |
| pkg@">=1.2 <2" | highest version in the range (quote it in the shell) |
| pkg@latest | the version tagged latest (the default) |
| pkg@next | the version tagged next, if the package publishes one |
Downgrade or pin a dependency
Running npm install pkg@<older> replaces the installed version and updates package-lock.json. To force a version for a transitive dependency, use the overrides field in package.json.
Sources
Related pages
flags · npmnpm install --legacy-peer-deps: what it does and when to use it--legacy-peer-deps makes npm skip installing and checking peer dependencies, as npm 6 did, so ERESOLVE conflicts no longer stop the install. Risks and fixes.compare · npmnpm ci vs npm install: differences and when to use eachnpm ci installs exactly what package-lock.json says, deletes node_modules first and never edits the lockfile; npm install resolves ranges and may update it.cheat sheets · npmnpm cheat sheet: install, run, update, publishnpm cheat sheet: init, install and uninstall, version specifiers, scripts, outdated and update, npm ci for CI, ls and explain, config and cache commands.