running npm install silently WITH devDependencies

problem: npm is too noisy!

specific problem: a VSTS build fails because VSTS treats npm warnings as errors (and npm outputs a LOT of warnings)

We use VSTS (Visual Studio Team Services) to build many client side projects, that install dependencies (custom + third party) via npm.

VSTS treats npm warnings as errors, which means that our VSTS build will always fail, when it runs 'npm install'.

So to install npm packages, we need to:

- configure VSTS to ignore npm warnings - not currently possible ?
- OR run npm install via the special npm task in VSTS
- OR run npm install silently

In order to reduce the number of builds that we must support, we have builds that are using a PowerShell script to iterate over many Apps and Component projects,
so in this case the VSTS npm task is not practical.

solution: run npm install silently

To run npm silently is not obvious:

npm install --silent does not install devDependencies! - we need gulp etc. to build...
and --dev installs ALL devDependencies recursively, which is too much.

so we use --loglevel error (hides info + warnings, but shows errors)

however - this can still result in some noise - so silencing by redirecting to stdout (on Windows box)...

 npm install --loglevel error > %TEMP%\npm_i_out.txt  

on a Unix box this would be something like:

 npm install --loglevel error > /dev/null   


_______________________________________
following notes:

on a dev box, it can also be handy to make npm less noisy.

this command runs npm install, only displaying warnings + errors (hiding info).

 npm install --loglevel warn  

to avoid downloading optional dependencies, I often add --no-optional:

 npm install --no-optional --loglevel warn  

hint: you can always use this command to check that all the dependencies are there OK:

 npm ls  


Comments