How to fix npm WARN deprecated npm WARN deprecated This command is deprecated. Use npm install instead in npm
npm deprecated command warnings appear when using outdated npm commands or flags. Common triggers include the deprecated --save flag (now default in npm 5+) and legacy commands like npm shrinkwrap.
Quick fix
Fixes npm WARN deprecated npm WARN deprecated This command is deprecated. Use npm install instead
npm install -g npm@latest
npm --version
# Should be v9+ or higher- Update npm to latest version
- Remove deprecated --save flags
- Replace npm shrinkwrap with package-lock.json
- Update deprecated strategy flags
npm install -g npm@latestnpm --version# Should be v9+ or highernpm WARN deprecated npm WARN deprecated This command is deprecated. Use npm install instead
What this error means
This warning indicates you're using an npm command or flag that's been superseded by newer functionality. While the command may still work, it's considered legacy and may be removed in future npm versions. npm evolves over time, and commands that were once standard become deprecated as better alternatives emerge. The warning helps you migrate to modern practices.
Typical symptoms
- Warning appears during npm commands without breaking them
- CI logs show deprecation warnings
- npm operations succeed but with warning messages
- Scripts using legacy flags produce warnings
Common causes
- Using deprecated --save flag (default since npm 5)
- Using legacy npm shrinkwrap instead of package-lock.json
- Using deprecated flags like --global-style or --legacy-bundling
- Dependencies relying on deprecated packages
- Old npm scripts not updated for modern versions
How to fix "npm WARN deprecated npm WARN deprecated This command is deprecated. Use npm install instead"
Ensure you have modern npm:
npm install -g npm@latest
npm --version
# Should be v9+ or higherThe --save flag is no longer needed (default since npm 5):
# Old (deprecated)
npm install --save lodash
npm install -S lodash
# New (modern)
npm install lodashUpdate package.json scripts:
{
"scripts": {
"add-dep": "npm install lodash"
}
}npm-shrinkwrap.json is deprecated:
# Remove shrinkwrap
rm npm-shrinkwrap.json
# Regenerate modern lock file
npm installThe package-lock.json serves the same purpose with better tooling support.
Legacy install flags have been replaced:
# Old (deprecated)
npm install --global-style
npm install --legacy-bundling
# New
npm install --install-strategy=hoisted # Default
npm install --install-strategy=nested # Minimal deduplication
npm install --install-strategy=shallow # Flat structureFor reproducible builds, use npm ci:
# GitHub Actions
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run testnpm ci is faster and more reliable than npm install in CI environments.
If warnings come from dependencies:
# See which packages are deprecated
npm ls <deprecated-package>
# Update parent packages
npm update parent-package
# Or check for alternatives
npm auditCommon deprecated packages to replace:
- request → axios or node-fetch
- npmlog → custom logging
- rimraf v3 → rimraf v4+
Advanced notes
Lifecycle script shortcuts still work:
- npm start = npm run start
- npm test = npm run test
But in CI/CD, prefer explicit commands: npm run test instead of npm test.
Package.json "engines" field can enforce npm version:
{
"engines": {
"npm": ">=9.0.0"
}
}Then in .npmrc: engine-strict=true
Frequently asked questions
- What does "npm WARN deprecated npm WARN deprecated This command is deprecated. Us" mean?
- This warning indicates you're using an npm command or flag that's been superseded by newer functionality. While the command may still work, it's considered legacy and may be removed in future npm versions. npm evolves over time, and commands that were once standard become deprecated as better alternatives emerge.
- How do I fix "npm WARN deprecated npm WARN deprecated This command is deprecated. Us"?
- npm deprecated command warnings appear when using outdated npm commands or flags. Common triggers include the deprecated --save flag (now default in npm 5+) and legacy commands like npm shrinkwrap.
- What causes "npm WARN deprecated npm WARN deprecated This command is deprecated. Us"?
- Using deprecated --save flag (default since npm 5) Using legacy npm shrinkwrap instead of package-lock.json Using deprecated flags like --global-style or --legacy-bundling
- Is the "npm WARN deprecated npm WARN deprecated This command is deprecated. Us" error serious?
- It is a low-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚npm Official Documentation
- 📖npm CLI documentation(Official Docs)
- 💬Stack Overflow: npm(Stack Overflow)