Upcoming breaking changes for npm v12

21 points by Jackevansevo


Gaelan

I've always found the emphasis on preinstall scripts (and their equivalents in other package managers) to be a bit silly - after all, the whole point of a package manager is to install arbitrary code. Even if npm install doesn't immediately run the code it downloaded, the next command you invoke after that probably will.

Admittedly, for a JavaScript package manager, this makes slightly more sense because some of the code the package manager installs might be destined to run in a browser, not the developer's machine. But:

Ultimately my view is that preinstall scripts are currently the path of least resistance for weaponizing a package compromise, so we currently see loads of them. (And as an individual, disabling preinstall scripts is perhaps a prudent defense, because you don't have to outrun the bear, just everyone else who gets exploited more easily than you.) But disabling preinstall scripts for everyone won't have a massive effect on the prevalence of supply chain attacks, it'll just move where in the package the malicious code goes.