22

I've been working with Node.js/npm for a while, but I never used npm scripts. I was quite surprised to find that I can't get them to work at all on my Windows/Cygwin system. With a package.json like this ...

{
  "name": "demo",
  "scripts": {
    "env": "env",
    "hello": "echo Hello!",
    "crap": "I am complete nonsense."
  }
}

... all three npm run commands do nothing. npm run crap executes and returns immediately with an OK status (I tested with the -dd parameter); npm run doesntexist throws the expected error. Testing without Cygwin on the regular Windows shell made no difference.

wortwart
  • 3,139
  • 27
  • 31

1 Answers1

42

I finally found out myself. There is an npm setting with which you can stop all npm scripts from running. For some reason, my userconfig file ~/.npmrc contained the setting ignore-scripts = true. If you run into this problem, check npm config list.

wortwart
  • 3,139
  • 27
  • 31
  • 6
    Thank you! Why wouldn't they print a warning message when `npm run` is called directly? :( – aleclarson Sep 13 '16 at 05:23
  • 6
    hahah wow funnily enough I set this to false after getting spooked by npm vulnerabilities but didn't realise the consequences! – Jesse Reza Khorasanee Nov 22 '19 at 03:27
  • This is insane. – Matthias Jul 31 '20 at 17:23
  • 1
    Oh my word why is this a thing!? I did the same as Jesse and forgot. npm please add some sort of warning for this. Like "It looks like you've disabled scripts in your .npmrc file. enable them to run local npm scripts" – James Nov 04 '20 at 12:20