Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a method to install peer dependencies of dependencies?

Tags:

dependencies

On running npm install, we get this:

npm WARN [email protected] requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself

Our initial belief was that the issue was a need to install the peer dependency mentioned - ajv - but that has not fixed the problem.

The important thing is simply understanding the issue. What does the error message even mean, given that we do have the dependencies satisfied AFAICT?

package.json has this:

  "dependencies": {
    "ajv": "^6.0.0"
  },

package-lock.json has this:

    "ajv": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.2.1.tgz",
      "integrity": "sha1-KKarxJOiq+D7TIUHrK7bQ/pVBnE=",
      "requires": {
        "fast-deep-equal": "1.1.0",
        "fast-json-stable-stringify": "2.0.0",
        "json-schema-traverse": "0.3.1"
      }
    },
    "ajv-keywords": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz",
      "integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=",
      "dev": true
    }

npm-install-peers gives

This package doesn't seem to have any peerDependencies

The maintainer of that tool says

It's designed to install the direct peer dependencies of your project, not the peer dependencies of your dependencies

which means the issue is a dependency deeper than the top level.

Is there a tool to install the dependencies of dependencies?

like image 713
Lucas Gonze Avatar asked Mar 13 '18 18:03

Lucas Gonze


2 Answers

Install the specific version of AJV that's being requested:

npm install ajv@^5.0.0 --save

(the ^ ensures that only minor, backward compatible updates will be installed for the package e.g. 5.1.0)

like image 65
Chris Halcrow Avatar answered Oct 21 '22 11:10

Chris Halcrow


I'm using firebase-admin and this issue poped as well, when I've updated to the version 7.0.0 of firebase-admin.

I've explicitly specified the latest version for both components and the warning is gone :

"ajv": "^6.10.0",
"ajv-keywords": "^3.4.0" 
like image 20
Thomas Avatar answered Oct 21 '22 10:10

Thomas