How to handle npm WARN deprecated messages when installing dependencies

Posted on Jun 28, 2022

Learn how to deal with npm WARN deprecated messages when you install packages

Photo from Unsplash

When installing packages using the npm install command, npm frequently generates a warning message that says a package is deprecated.

The example warnings can be seen below:

npm WARN deprecated source-map-url@0.4.1:
  See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0:
  Please see https://github.com/lydell/urix#deprecated

The npm WARN deprecated message means that the package installed on your project is not recommended for use.

This may be due to issues found with the package or it’s no longer maintained.

You may not even see these packages in your package.json file because they are dependencies of the packages that you are using.

For example, the deprecation warning above appears when I install the gulp package.

Only the gulp package maintainer can update the dependencies and resolve the error, so I can’t do anything about it.

If you find the same deprecation messages, then you can try to see if there’s an open issue in GitHub discussing the deprecation messages.

Sometimes, you may see a deprecation message that encourages you to update the package version as follows:

npm WARN deprecated minimatch@0.3.0: 
  Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

While you can run the npm install command to get the required package version, it’s not necessary as the module should still work.

Again, the dependency must be updated in the package.json file of the package you are installing.

If you want to remove the deprecated warnings, you can add the --loglevel=error option when running npm install:

npm install --loglevel=error

With the option added, only error messages will be printed when installing your dependencies.

And now you’ve learned how to handle npm WARN deprecated messages when running the npm install command. Nice work!

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.