What Happened When I Peeked Into My Node_Modules Directory

Just absolute madness

Jordan Scales

--

Photo: Mint Images/Getty Images

The left-pad fiasco shook the JavaScript community to its core when a rouge developer removed a popular module from npm, causing tens of projects to go dark.

While code bloat continues to slow down our websites, drain our batteries, and make “npm install” slow for a few seconds, many developers like myself have decided to carefully audit the dependencies we bring into our projects. It’s time we as a community stand up and say enough is enough, this community belongs to all of us, not just a handful of JavaScript developers with great hair.

Am I being paranoid? Maybe. Am I overestimating the hard work that goes into running an open source project? Most likely. Was I kicked off my ZogSports team because I “make sports less fun for everyone involved”? Yes.

I decided to document my experiences in auditing my projects’ dependencies, and I hope you find the following information useful.

Express

Behind the fastest, leanest JavaScript web framework is a heaping pile of dependencies, each with their own heaping pile of dependencies. In fact, a simple “npm install express” leads to 291 installed modules.

$ tree node_modules/ | count
zsh: command not found: count
$ tree node_modules/ | lines
zsh: command not found: lines
$ tree node_modules/ | wc -lines
wc: illegal option — i
usage: wc [-clmw] [file …]
$ tree node_modules/ | wc -countlines
wc: illegal option — o
usage: wc [-clmw] [file …]
$ man wc
$ tree node_modules/ | wc -l
292

Imagine if the apple you were eating for breakfast had 291 ingredients, or if the car you drove to work had 291 parts. You’d be worried, wouldn’t you? Yet, for some reason, we’re totally fine installing 291 individual modules just to power an enterprise-grade web server capable of handling thousands of incoming requests per second.

So, what’s in these dependencies anyway? Many are self-explanatory: “range-parser” parses ranges, “escape-html” escapes html, and “negotiator” makes great deals.

However, one dependency — “yummy” — caught my attention.

├── yummy
│ ├── LICENSE
│ ├── README.md
│ ├── like-tweet.js
│ ├──…

--

--

Jordan Scales

JavaScript clickbait enthusiast. Giving you superpowers.