Skip to content

/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

bash
npm init -y >/dev/null
npm install --no-audit --no-fund lodash@4.17.21
npm ls lodash
npm pkg get dependencies

Output

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

bash
npm view lodash@4.17 version
npm view lodash dist-tags

Output

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

SpecifierInstalls
pkg@1.2.3exactly 1.2.3
pkg@^1.2.3highest 1.x.x that is >= 1.2.3
pkg@~1.2.3highest 1.2.x that is >= 1.2.3
pkg@">=1.2 <2"highest version in the range (quote it in the shell)
pkg@latestthe version tagged latest (the default)
pkg@nextthe 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