Is it possible to install npm package only if it has not been already installed?
npm
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.
npm install [email protected]
node_modules
protractor --version
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.
with bash you can do
[ $(node -p "require('protractor/package.json').version") != "2.1.0" ] && npm install [email protected]
2.1m questions
2.1m answers
60 comments
57.0k users