4

I have two local npm projects, A and B. Let's say A depends on react and has it listed as a dependency in the package.json file. I use npm link to make A available for B.

B depends on A and react. I use npm link A to use the local version of A. However, as I know that A already depends on react, I do not include react in my package.json file of B. When I call npm install I would expect npm to include transitive dependencies in the node_modules folder. However, I cannot find react in it nor can I use it in B's code as long as I don't include the transitive dependency in B's own package.json file.

When I include other modules like react, I also get transitive dependencies like fbjs or encoding resolved into my node_modules folder.

So, where is the mistake? / Why are the dependencies of A not included in B's node_modules folder?

Salim
  • 2,446
  • 1
  • 14
  • 12

1 Answers1

3

I got the same behaviour with npm 5.6. After a downgrade of npm to 4.6 version, "npm install" ran right. After this I figured out the problem was a package-lock.json committed by a teammates of mine and not synchronized to package.json

Fabio Formosa
  • 904
  • 8
  • 27