16

I have lot of dependencies installed. while npm install I am getting npm warn deprecated please update to some version. how to find which package produces this warning.

Gary Sheppard
  • 4,764
  • 3
  • 25
  • 35
Sibiraj
  • 4,486
  • 7
  • 33
  • 57

4 Answers4

14

npm outdated only shows packages that have newer versions available, independent of their deprecation status. Thus, it does not show deprecated packages that won't get updates anymore (e.g. request or @hapi/joi).

If you use npm version 7 or newer, you should have a package-lock.json with lockfileVersion: 2. This lockfile contains the deprecation warnings of all installed packages.

You can use jq to find all packages that have deprecation warnings:

jq -r '.packages | to_entries[] | select(.value.deprecated != null) | "\(.key):\n\(.value.deprecated)\n"' package-lock.json 

The output will look like this:

node_modules/har-validator:
this library is no longer supported

node_modules/request:
request has been deprecated, see https://github.com/request/request/issues/3142

node_modules/request-oauth/node_modules/uuid:
Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.

node_modules/request/node_modules/uuid:
Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
abrain
  • 350
  • 3
  • 7
  • 1
    If this returns transitive dependencies that aren't declared in your package.json, `npm explain ` will show the declared dependencies are bringing them in. – ParkerM Nov 20 '22 at 00:45
1

Open your terminal and run these two commands:

  1. cd
  2. npm outdated

It should return a list of outdated packages that need to be upgraded.

triedit
  • 169
  • 1
  • 9
  • 7
    Deprecated notices come from sub-dependencies. `npm outdated` does not consider sub-dependencies. Updating direct dependencies might fix the issue, or it might not. – fregante Dec 28 '20 at 01:15
1

Problem: npm i gives you warns about a deprecated sub-dependency.

Fix: npm list --depth=3 >> result.txt then you can search in that file for the deprecated sub package

David Rearte
  • 764
  • 8
  • 19
0

There is a package can do this.

npm install -g npm-deprecated-check
ndc 
W.Perrin
  • 4,217
  • 32
  • 31