"I had a problem. I started using regex and now I have two problems."
Becomes...
"I had a problem. I ran npm install and now I have 21,735 problems."
"I had a problem. I started using regex and now I have two problems."
Becomes...
"I had a problem. I ran npm install and now I have 21,735 problems."
Think about that for a moment: one library, 40 versions downloaded and compiled to fill NPM dependencies. What if there was a vulnerability in a version of that library - how do I audit that? Can I even fix it myself without hosting my own NPM registry? Bandwidth? Computation costs (a thing again, with cloud computing)? Disk space costs?
It makes me glad we just use Docker; so I don't have to try and make sense of the NPM madness from day-to-day. Just Docker's own brand of madness.
NPM on Windows also had other problems such as Python path is wrong or C++ compiler is missing.
Then we switched to Yarn. Uncached install took about 2-3 minutes, and cached install would finish in seconds.
Recently, NPM 5 has been released, and it's been competing well against Yarn.
Also, Yarn's run command can be used to run locally installed NPM binaries, not just NPM scripts. i.e., you can do `yarn run -- webpack` and it will run the local copy of Webpack. This is handy imo, and as far as I know NPM doesn't do it.
I like Yarn run, because if I'm running a lint or tests, it errors out with error messages related to the specific process.
If you run via npm run, it would throw lot of extra error messages, making excuses that it wasn't NPM's fault the command exited with a non-zero status etc.; and hiding the relevant error messages.
And as always, you can just run a script as yarn script, instead of yarn run script; like yarn lint:src, instead of yarn run lint:src.
NPM does it only for a few common ones.
Also, Yarn run picks up right node version from .nvmrc - you don't have to run an nvm use and switch to it.
ES7 is okay, Node.js is good, V8 is GREAT, but NPM is an atrocity.