Re:'No way to prevent this,' says only package manager where...
by joeblubaugh on Friday May 15, 2026 @10:32PM
(#48156292)
There has been a lot of pain at my various jobs installing a safe global npm config on every developer machine, asking people not to disable it, checking it with mdm tools. A safer out-of-the-box configuration is long overdue.
[ Parent
| on HN ]
Re:'No way to prevent this,' says only package manager where...
by tkel on Friday May 15, 2026 @10:36PM
(#48156317)
Just dont use npm. Use a package manager which doesn't execute postinstall by default. The switch is incredibly simple.
Re:'No way to prevent this,' says only package manager where...
by cluckindan on Friday May 15, 2026 @10:38PM
(#48156332)
Which package manager is that, and what caveats does it offer?
Re:'No way to prevent this,' says only package manager where...
by timfsu on Friday May 15, 2026 @10:44PM
(#48156364)
Pnpm - installs are faster to boot. We haven’t missed anything
Re:'No way to prevent this,' says only package manager where...
by ricardo_lien on Friday May 15, 2026 @10:44PM
(#48156365)
pnpm
Re:'No way to prevent this,' says only package manager where...
by joeblubaugh on Monday May 18, 2026 @04:42AM
(#48176909)
It’s hard to enforce on developer machines - there are lots of ways to install npm even if you never use it for managing development dependencies.
Re:'No way to prevent this,' says only package manager where...
by 10000truths on Saturday May 16, 2026 @01:00AM
(#48156973)
What do you mean by safe config? If you're trying to mandate a cooldown period or a whitelist/blacklist of packages, the correct approach is to configure a company-controlled registry that pulls from the upstream npm registry while enforcing your desired policies.
Re:'No way to prevent this,' says only package manager where...
by tkel on Saturday May 16, 2026 @02:08AM
(#48157287)
Or even just a proxy that can enforce the constraints
Re:'No way to prevent this,' says only package manager where...
by Macha on Saturday May 16, 2026 @07:52AM
(#48159345)
Whether the config is the registry URL or the cooldown timer you still need it on your dev machines and people to use tools that use it (the latter is especially a problem with docker in my experience, people find out testcontainers or whatever is pulling from docker hub rather than the company registry only when their CI build fails from rate limits)
Re:'No way to prevent this,' says only package manager where...
by 10000truths on Saturday May 16, 2026 @05:16PM
(#48163897)
What I'm saying is that the policy should be enforced server-side. So you block the npm registry in the company firewall, and set up a company-specific registry that acts as a blessed proxy to the npm registry but enforces your desired policies. For example, if you configure your registry to refuse to pull packages published less than a week ago, then it doesn't matter if a client disables dependency cooldowns in their npm config - they still won't be able to "npm install totally-new-not-a-virus-pkg".
People can still bypass these measures if they're determined enough (offline package installs, vendoring dependencies, etc.) but making circumvention impossible to do accidentally and inconvenient to do deliberately solves the problem 99% of the way.