how to install multiple versions of package using npm

As of npm v6.9.0, npm now supports package aliases. It implements the same syntax as Yarn uses:

npm install jquery2@npm:jquery@2
npm install jquery3@npm:jquery@3

This adds the following to package.json:

"dependencies": {
   "jquery2": "npm:jquery@^2.2.4",
   "jquery3": "npm:jquery@^3.4.1"
}

It is also possible to install directly from GitHub with this syntax. For example, if you want to install both the npm registry version and a GitHub fork of the package foobar:

npm install foobar
npm install foobar-fork@github:username/foobar

Leave a Comment

tech