How can I install npm package smaller than any specific version

Viewed 7556

Let me explain....

Like.. I want to install jQuery package using npm, and the version of jquery is smaller than 3.0.0.

So how can I do it?

4 Answers

I think you must update the dependency version in "package.json" (which you required) and then run the "npm install" command.It will update the package with which we added in the "package.json" file. Hope this will fix the issue.

Fist of all,
for having a better picture of the jquery,
you can get the available jquery versions, on your terminal, likes so: npm view jquery versions

This command will give you the whole history of available versions, so far: enter image description here

So, some other ways to install jquery on smaller versions to ver. 3.0.0 are:

  • As previously mentioned: npm i jquery@"<3.0.0" or npm i jquery@">1.6.2 <3.0.0"
  • By using the ^ symbol, like: npm i jquery@^2.0.0 or npm i jquery@2.0.x or npm i jquery@^2 or npm i jquery@^2.*.

The ^ symbol covers all the range, from the mentioned minor, until the previous version of the next major version.(^MAJOR.MINOR.PATCH).

e.g. jquery@^2.1.3, will install from version >= 2.1.3 < 3.0.0

You can play, with the npm semver calculator here : https://semver.npmjs.com/

Related