How to force npm to use the jquery 2.1.1

2020-07-05 07:54发布

问题:

I am asking this question as a beginner on node-npm. My current node_modules has a query version 2.2.0. But in the same project i am using materialize-css which has a datepicker component.

This component runs on jquery 2.1.1. My question is simple.

How can i remove the current jquery [v 2.2.0] from my node_modules and install jquery version [2.1.1] so that the datepicker component works.

回答1:

Add the specific version to your package.json :

"dependencies": {
    "jquery": "2.1.1"
}

Then, run the following command :

npm update


回答2:

You can use the npm CLI to install the dependency directly without changing the dependencies yourself in package.json by typing:

npm install jquery@2.1.1



回答3:

Thanks for helping out. I went to my package.json file and added dependency as

"dependencies": {
  "jquery": "2.1.1"
}

after this I did sudo npm update to the existing project and it changed the jquery version to 2.1.1. I assume sudo npm install would also have same effect