[英]package.json dependencies exact version not working
This is an excerpt from my package.json
: 这是我的package.json
的摘录:
"dependencies": {
[...]
"jquery": "2.2.3",
[...]
}
According to the package.json documentation ("must match version exactly ") it should get jQuery with version 2.2.3 when you do npm install
. 根据package.json文档 (“必须完全匹配版本”),当您执行npm install
时,它应该使用2.2.3版本的jQuery。
So I was surprised when I found that in my node_modules/jquery/dist
folder there is a jquery.js
file which says: jQuery JavaScript Library v3.0.0 (Which, of course, broke some of my code) 因此,当我发现在我的node_modules/jquery/dist
文件夹中有一个jquery.js
文件,上面写着: jQuery JavaScript Library v3.0.0 (当然,其中的一些代码node_modules/jquery/dist
时,我感到惊讶。
What happened here? 这里发生了什么? Is this a bug? 这是错误吗? Is this intended behaviour because some other dependency has a jQuery@3.0.0 sub-dependency? 这是预期的行为,因为其他一些依赖项具有jQuery@3.0.0子依赖项吗? Same occurs when I put the caret in front of the version number ( "jquery": "^2.2.3"
). 当将插入号放在版本号( "jquery": "^2.2.3"
)前面时,也会发生同样的情况。 Could not find anything about this in the docs, on SO or on google, so any help will be appreciated. 无法在文档中,SO或google上找到与此有关的任何内容,因此将不胜感激。
Do you have a npm-shrinkwrap.json
file, which makes npm ignore all changes to your package.json
dependencies (devDependencies are not affected) and has a hardcoded jquery@3.0.0 version? 您是否有一个npm-shrinkwrap.json
文件,该文件使npm忽略对package.json
依赖项的所有更改(devDependencies不受影响)并且具有硬编码的jquery@3.0.0版本?
Delete that file and run npm install
again. 删除该文件,然后再次运行npm install
。
If you need to, run npm shrinkwrap
again afterwards to re-create the shrinkwrap file with the new version numbers. 如果需要,请稍后再次运行npm shrinkwrap
,以使用新的版本号重新创建shrinkwrap文件。
See documentation here: https://docs.npmjs.com/cli/shrinkwrap 请参阅此处的文档: https : //docs.npmjs.com/cli/shrinkwrap
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.