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.
Check the ignore-script config If you see the start script is present inside your package. json file but still can't run the script, you need to check the console output. If there's no output at all, then you may have the ignore-scripts npm configuration set to true .
npm run sets the NODE environment variable to the node executable with which npm is executed. If you try to run a script without having a node_modules directory and it fails, you will be given a warning to run npm install , just in case you've forgotten.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With