Npm.depends in both app and local packages creates duplicates


I am using React for my application and want to keep things modular so I try to write as much code inside packages as possible.

So in my application, I ran:

meteor npm install --save react react-dom react-router

And in some of my package code, which provide the React components, I have the following inside my package.js

  "react": "15.1.0",
  "react-router": "2.4.1"

What this does is create a node_modules directory in both the application and package


This is redundant. Furthermore, I’ve ran into problems where the code does not work because multiple version of React was loaded.

So what should happen when my package depends on React? I see two ways:

  • I leave out Npm.depends in the package and add it in the application? This doesn’t make sense because all a package’s dependency should be defined in the package.js.

  • I use Npm.depends and do not run meteor npm install --save react? This makes more sense but restricts all my code to be inside packages. And it still leaves the problem of duplicated npm packages being downloaded inside each package.

Either way, it’s not ideal. So how are you guys dealing with this right now?

Thanks in advance for any advice you can offer!


I just came across this - and this looks like a big problem. Did you every find a resolution to this?


I know this is way old, but I came across this in a search so wanted to provide info for other searchers.

I think you can solve this using peer npm dependencies with check-npm-versions.