4

I have a main project which depends on a package package1 in the local file store. package1 peer depends on express:

{
  "name": "package1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "peerDependencies": {
    "express": "^4.17.1"
  }
}

In the folder of the main project I do

npm install ../packages/package1

With npm@6.x it installs package1 as a link in node_modules of the main project, as expected. It also gives me a warning, that a peer dependency is missing - as expected.

Now I use npm@7.17 for the same task. Either with --legacy-peer-deps option or without. It installs package1 as a link in node_modules of the main project. But it does NOT install the peer dependency in the main package NOR does it give my a warning, that a peer dependency is missing.

I exepected either a warning (at least with -legacy-peer_deps switched on) or express installed in the main project. BTW, it also does not get installed in the node_modules of package1.

Any idea anybody? I'd appreciate it much.

andreash
  • 123
  • 6

1 Answers1

0

The same is happening to me, and based on this comment https://stackoverflow.com/a/57915074/473967 looks like peerDependencies are for the host package but won't install on the "plugin" package, so we need to add it twice, on the dependencies (or devDependencies) AND on the peerDependencies to let the host know.

Javis Perez
  • 4,130
  • 3
  • 23
  • 27