Menu

Your .npmrc Says Ignore-Scripts. The Repo's .npmrc Says Otherwise — and the Repo Wins
📰

Your .npmrc Says Ignore-Scripts. The Repo's .npmrc Says Otherwise — and the Repo Wins

DEV Community: javascript·AheadKit·3 days ago
#yAA9Wt4h
#devtojavascript#devto#dev#install#file
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.