How to fix npm WARN deprecated npm WARN deprecated This command is deprecated. Use npm install instead in npm

npmINTERMEDIATELOWUpdated Dec 3, 2025· 194 views

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
  1. Update npm to latest version
  2. Remove deprecated --save flags
  3. Replace npm shrinkwrap with package-lock.json
  4. Update deprecated strategy flags
npm — error
npm install -g npm@latest
npm --version
# Should be v9+ or higher
npm 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

  1. Using deprecated --save flag (default since npm 5)
  2. Using legacy npm shrinkwrap instead of package-lock.json
  3. Using deprecated flags like --global-style or --legacy-bundling
  4. Dependencies relying on deprecated packages
  5. 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"

1Update npm to latest version

Ensure you have modern npm:

bash
npm install -g npm@latest

npm --version
# Should be v9+ or higher
2Remove deprecated --save flags

The --save flag is no longer needed (default since npm 5):

bash
# Old (deprecated)
npm install --save lodash
npm install -S lodash

# New (modern)
npm install lodash

Update package.json scripts:

json
{
  "scripts": {
    "add-dep": "npm install lodash"
  }
}
3Replace npm shrinkwrap with package-lock.json

npm-shrinkwrap.json is deprecated:

bash
# Remove shrinkwrap
rm npm-shrinkwrap.json

# Regenerate modern lock file
npm install

The package-lock.json serves the same purpose with better tooling support.

4Update deprecated strategy flags

Legacy install flags have been replaced:

bash
# 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 structure
5Use npm ci in CI/CD environments

For reproducible builds, use npm ci:

yaml
# GitHub Actions
- name: Install dependencies
  run: npm ci

- name: Run tests
  run: npm run test

npm ci is faster and more reliable than npm install in CI environments.

6Update deprecated dependencies

If warnings come from dependencies:

bash
# See which packages are deprecated
npm ls <deprecated-package>

# Update parent packages
npm update parent-package

# Or check for alternatives
npm audit

Common 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:

json
{
  "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