Shan-Desai
Shan-Desai

Reputation: 3349

Why does npm install two different version of the same dependency when installed separately

Scenario 1

Terminal: Windows cmd

node version: v8.0.0

npm version: v5.5.1

I have a package.json where I specifically mention

"@swimlane/ngx-charts": "^7.3.0",
"@swimlane/ngx-graph": "^4.3.0",

These have a subdependency on d3-scale.

In this scenario the npm install command installs d3-scale: v2.0.0 which has dist/ folder in it. (Note: I use d3-scale/dist in a systemjs.config.js file for an Angular App)

Scenario 2

Terminal: Windows Subsystem For Linux (bash for ubuntu for windows)

node version: v8.11.1

npm version: v5.6.0

I perform npm install with the same package.json and this time it provides me with d3-scale: v1.0.7 which has build/ folder instead of dist/ quick comparison on d3-scale.

Now because of this discrepancy I had to change my systemjs.config.js to point to build for a local machine.

If the app gets deployed on the server or a cloud I am not sure which d3-scale it might download in the node_modules and I might have to commit a hotfix for it.

Question

Why is there a discrepancy in the first place? What is causing this?

Upvotes: 0

Views: 641

Answers (1)

Anditthas
Anditthas

Reputation: 541

It seems that the NPM team resolved an issue in v5.6.0.

Fully cross-platform package-lock.json. Installing a failing optional dependency on one platform no longer removes it from the dependency tree, meaning that package-lock.json should now be generated consistently across platforms!

Source

So try to upgrade your windows NPM to v5.6.0. It should work now.

Upvotes: 1

Related Questions