Is it possible to install npm
package only if it has not been already installed?
I need this to speed up test on CircleCI, but when I run npm install [email protected]
etc. it always downloads things and installs them from scracth, however, node_modules
folder with all modules is already present at the moment of running commands (cached from previous build) and protractor --version
etc. shows the needed version of the package.
Its perfect to have some one-line command like this:
protractor --version || npm install -g [email protected]
but the one that will also check version of the package.
it always downloads things and installs them from scracth, however, node_modules folder with all modules is already present at the moment of running commands (cached from previous build) and protractor --version etc.
Yes, but simply copying the content of node_modules should be enought, unless you install globally. Another way that may be simpler is to run npm install angular-cli on a connected system, and copy the content of node_modules to the offline computer.
1 Answer. Show activity on this post. NPM is extremely useful, but, when you install it, you install it globally. It comes with Node JS, so when you install Node JS, you should have npm installed(type npm -v to see the version and whether npm is installed).
You could try npm list protractor || npm install [email protected]
Where npm list protractor
is used to find protractor
package.
If the package is not found, it will return npm ERR! code 1
and do npm install [email protected]
for installation
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