Is there a way to install and also use the different package versions in npm
? Installations works:
npm install -g [email protected]
npm install -g [email protected]
npm install -g [email protected]
I can install npm install -g [email protected]
and check npm view web3 versions
them. But how can I use them in the *.js
script? Something like this:
require('[email protected]');
require('[email protected]');
require('[email protected]');
There is a node module that allows you to do it.
npm-install-version
Install it: npm install npm-install-version --save-dev
var niv = require('npm-install-version');
niv.install('[email protected]');
niv.install('[email protected]');
var package_old = niv.require('[email protected]');
var package_new = niv.require('[email protected]');
I did some research and it seems that its not possible with standard NPM. Here is the feature-request: https://github.com/npm/npm/issues/5499
However, with yarn
(an NPM alternative from Facebook), you can do it out of the box by using yarn add
and giving the package an alias.
I have not tried this for globally installed packages though, I assume it works the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With