简体   繁体   中英

package.json dependencies exact version not working

This is an excerpt from my 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 .

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)

What happened here? Is this a bug? Is this intended behaviour because some other dependency has a jQuery@3.0.0 sub-dependency? Same occurs when I put the caret in front of the version number ( "jquery": "^2.2.3" ). Could not find anything about this in the docs, on SO or on google, so any help will be appreciated.

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?

Delete that file and run npm install again.

If you need to, run npm shrinkwrap again afterwards to re-create the shrinkwrap file with the new version numbers.

See documentation here: https://docs.npmjs.com/cli/shrinkwrap

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