Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Npm missing peer dependency

I do not know how to fix below peer dependency error.

mondwan@mondwan-All-Series:~/Documents/git/py-cli_build_tools$ sudo npm -g list | grep eslint     ├─┬ [email protected] ├─┬ [email protected] ├─┬ [email protected] │ └── [email protected] ├─┬ [email protected] ├─┬ [email protected] │ ├─┬ [email protected] │ ├─┬ [email protected] ├─┬ UNMET PEER DEPENDENCY [email protected] ├─┬ [email protected] npm ERR! peer dep missing: eslint-plugin-jsx-a11y@^2.2.3, required by [email protected] 

As you see, I have installed [email protected] which is definitely fulfill ^2.2.3 required by

eslint-config-airbnb. However, it shows such error message. Any idea for solving such problem?

like image 231
Mond Wan Avatar asked Dec 22 '16 03:12

Mond Wan


People also ask

Does npm automatically install peer dependencies?

A command-line interface to install an NPM package and its peer dependencies automatically. Starting with NPM v3. 0, peer dependencies are not automatically installed on npm install , and it can be a hassle to install them all manually.

How do you resolve peer dependencies?

Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.

What is npm Peer dependency?

Peer Dependencies are used to specify that our package is compatible with a specific version of an npm package. Good examples are Angular and React. To add a Peer Dependency you actually need to manually modify your package.json file.

How do I add a dependency in npm?

To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.


1 Answers

I have mis-understood the meaning of the ^ in version ^2.2.3.

After reading this link, ^2.2.3 means >=2.2.3 <3.X. That's why npm throws an warning.

Besides, below are links about peer-dependencies

  • What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
  • https://nodejs.org/en/blog/npm/peer-dependencies/
like image 82
Mond Wan Avatar answered Oct 07 '22 10:10

Mond Wan