13

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.

Prakhar
  • 1,065
  • 3
  • 16
  • 30
  • 1
    How about don't use npm and download directly the version you need and put it in your assets by hand? – Stan Jan 12 '16 at 13:09
  • 2
    In your `package.json`file you can specify which version you'd like to use: `"jquery":"2.1.1",` in the `"dependencies"` portion. Then do a npm install. – Juan Stiza Jan 12 '16 at 13:16

3 Answers3

20

Add the specific version to your package.json :

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

Then, run the following command :

npm update
w3spi
  • 4,380
  • 9
  • 47
  • 80
xkcd149
  • 842
  • 1
  • 11
  • 17
  • 2
    And then run `nmp install` to install missing packages. Or there's this [npm-install-missing](https://www.npmjs.com/package/npm-install-missing) module that handles missing dependencies too. – Aaron Jan 09 '17 at 21:46
  • My issues relating to this was that i was having my jquery inside "devDependencies" rather than "dependencies". Thanks for noting that! – Abdulaziz Hamdan Jun 21 '23 at 07:10
6

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

mtpultz
  • 17,267
  • 22
  • 122
  • 201
0

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

Prakhar
  • 1,065
  • 3
  • 16
  • 30