[英]Why does npm install two different version of the same dependency when installed separately
Terminal : Windows cmd
终端 :Windows
cmd
node version : v8.0.0
节点版本 :
v8.0.0
npm version : v5.5.1
npm版本 :
v5.5.1
I have a package.json
where I specifically mention 我有一个
package.json
,我特别提到
"@swimlane/ngx-charts": "^7.3.0",
"@swimlane/ngx-graph": "^4.3.0",
These have a subdependency on d3-scale
. 这些对
d3-scale
有从属关系。
In this scenario the npm install
command installs d3-scale: v2.0.0
which has dist/
folder in it. 在这种情况下,
npm install
命令将安装d3-scale: v2.0.0
,其中包含dist/
文件夹。 (Note: I use d3-scale/dist
in a systemjs.config.js
file for an Angular App) (注意:我在Angular App的
systemjs.config.js
文件中使用d3-scale/dist
)
Terminal : Windows Subsystem For Linux ( bash for ubuntu for windows
) 终端 :Windows子系统(对于Linux)(
bash for ubuntu for windows
Windows bash for ubuntu for windows
)
node version : v8.11.1
节点版本 :
v8.11.1
npm version : v5.6.0
npm版本 :
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 . 我使用相同的
package.json
执行npm install
,这一次它为我提供了d3-scale: v1.0.7
,它具有build/
文件夹,而不是d / scale上的dist/
快速比较 。
Now because of this discrepancy I had to change my systemjs.config.js
to point to build
for a local machine. 现在,由于这种差异,我不得不更改
systemjs.config.js
使其指向为本地计算机build
的代码。
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. 如果该应用程序已部署在服务器或云上,我不确定它可能会在
node_modules
下载哪个d3-scale
,并且我可能必须为此提交一个修补程序。
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. NPM团队似乎解决了v5.6.0中的一个问题。
Fully cross-platform package-lock.json.
完全跨平台的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!
在一个平台上安装失败的可选依赖项不再将其从依赖项树中删除,这意味着package-lock.json现在应该在所有平台上一致地生成!
So try to upgrade your windows NPM to v5.6.0. 因此,请尝试将Windows NPM升级到v5.6.0。 It should work now.
现在应该可以工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.