I added one line to my own npm config a few months ago and stopped worrying about install hooks. The line was ignore-scripts=true, sitting in my user-level .npmrc, and in my head it worked like a lock on my front door. Any package I installed could bring whatever code it wanted in its install step, and my machine would just refuse to run it. That was the deal I thought I'd made with npm.
Then cryptostrapon asked a question in the comments on the install-hooks piece that I couldn't answer from memory. If a repo ships its own .npmrc that says ignore-scripts=false, does that beat my setting? I had a guess. My guess was wrong in the direction that matters, so I ran the test instead of arguing from memory.
The test was small on purpose. I built a package with one preinstall hook and nothing else. The hook writes a small marker file with a timestamp and prints a line, and the package itself does nothing at all. Then I installed it three ways on my own machine, node v24.22.1 and npm 10.9.4, and checked for the marker file after each install. The marker file is the whole test. If it's there, the hook ran. If it's not, it didn't.
Problem 1: the repo outranks you.
npm reads its config in layers, and the project layer sits on top. A .npmrc in the project folder beats the one in your home folder, which beats the global one, which beats the built-in defaults. I knew this in the abstract. I had never watched it eat my own safety setting.
First install: only my user config in play, ignore-scripts=true, no repo config at all. I asked npm what the effective value was and it said true. The install finished, and there was no marker file. The hook stayed silent. So far, the lock worked.
Second install: same user config, untouched. The only change was a repo .npmrc with one line in it, ignore-scripts=false. I asked npm for the effective value again and it said false. My own setting, in my own home folder, had just lost a vote I didn't know was happening. The install finished, and this time the marker file was there, timestamped 2026-11-17T00:07:40Z. The hook had run. I ran that second install again later to keep a clean copy of the marker as evidence, and it wrote a fresh one at 00:08:49Z. Same result twice.
That is the shape of the problem. Your personal setting is not a lock. It's a default, and a default is exactly the kind of thing a project folder is allowed to replace. One line in a repo you just cloned can switch your protection off, and the file that does it sits in plain sight in the repo root, in a file most of us never open before installing.
And before anyone pictures a villain: most repos that set ignore-scripts=false are not trying anything. Plenty of them do it for a boring, legitimate reason. Native packages and build tools often need their install hooks to finish setup, and a repo that sets the value to false is usually just making sure a fresh clone works the first time for everyone. The setting is doing its job. The problem is that the same file, with the same one line, is also the whole attack surface, and nothing in the process distinguishes a helpful repo from a hostile one. Your user config can't tell the difference either. It just loses.
Problem 2: nothing tells you it happened.
This is the part that bothered me more than the override itself. The two installs looked identical from the outside. Both printed the same calm line, "added 1 package". The second one even swallowed the hook's own printed line. The hook ran, wrote its file, and npm showed me nothing about it. I only knew because I went looking for the marker file on purpose.
Think about what that means for a real install. You clone something, you run the install, the output looks normal, and a hook you believed you'd blocked has already run. There is no warning, no yellow text, no hint that your setting lost. The tool did exactly what its config layers told it to do. It just never told you which layer won.
I keep coming back to that silence, because it breaks the one feedback loop that would save you. If npm printed one line, something like "project config turned install hooks back on", the whole issue would be a footnote. You'd see it, shrug, and decide for yourself. Instead the decision happens in a file you didn't write, in a layer you didn't know was voting, and the output looks the same either way. A protection that fails silently is worse than no protection at all, because the silent one still lets you feel safe.
Problem 3: the command-line flag is the only setting that's actually yours.
Third install: same repo config, still saying false, but this time I added --ignore-scripts to the install command itself. The hook stayed silent. No marker file. The flag beat the repo file, the way the repo file had beaten my user config.
That ordering is the honest picture. A flag you type wins over every file. A file in the project wins over a file in your home folder. A file in your home folder only wins when nothing above it has an opinion. Your user config is the weakest voice in that room, and it's the one most of us trust the most.
The catch is obvious, and it's the reason this matters less than it should and more than it does. A flag only protects the install where you remember to type it. Nobody types a flag on every install. We set a config once, forget about it, and trust it forever. That's the whole appeal of a user-level setting, and it's exactly the trust the layering quietly breaks.
So what do I actually do with this now? I stopped treating ignore-scripts=true in my own config as a safety net and started treating it as a preference. For installs I care about, the flag goes on the command. For repos I don't know well, I look at the .npmrc before the install, the same way I'd glance at a package's install hook before running it. It takes ten seconds, and it's the only check that can't be overridden by the thing it's checking. If a repo needs its hooks to build, fine, that's a real reason, and I can decide that with my eyes open instead of finding out afterwards.
Problem 4: the honest limit of this whole test.
Everything above is about install time. A package with no install hook at all can still run code the first time you load it, and no ignore-scripts setting, flag or config file touches that. That's the PolinRider pattern, and I'm not going to pretend I reproduced it here. I didn't. My test package was built to answer one question, whether a repo config beats a user config at install time, and it answered it. The load-time door is a different test, and it deserves its own run before anyone writes about it with confidence.
So the claim stands, and it's a narrower claim than the headline version. Your ignore-scripts setting does protect you, right up until a repo disagrees with it. Then the repo wins, quietly, and the only thing that reliably overrules the repo is a flag you type yourself, every time.
Have you ever caught a repo config undoing something you set for yourself? Not just npm. Any tool where a project file outranked your personal setup and you only found out later. I'd like to hear how you found it, and what you changed after.
P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam

