简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM