I am no Windows kernel or any .. expert. In my case the test script kept erroring out with the message npm is not recognized as an Internal or External command.
a) When I had it as
"test": "mocha **/*.test.js",
"test-watch": "nodemon --exec 'npm test'"
It ran a few times and stopped and the error started occurring so when I switched to
"test": "mocha **/*.test.js",
"test-watch": "nodemon --exec \"npm test\""
Still I kept getting the same error of npm not recognized...
And no matter how many times I issued Ctrl c, the nodemon wouldn't stop.
I did take the steps of restarting my laptop, uninstalled and re-installed nodeJs, updated the PATH variable in Control Panel - User Accounts - Environment variables all amounting to no end in sight.
This leads me to believe that somewhere or somehow, either nodemon or mocha not sure, what is hanging, so even after I had modified to escape and use double quotes as in
"test": "mocha **/*.test.js",
"test-watch": "nodemon --exec \"npm test\""
I still kept getting the same error.
b) So then I changed the name of the key from test-watch to test-new
"test": "mocha **/*.test.js",
"test-new": "nodemon --exec \"npm test\""
and ran
npm run test-new
and every tests runs fine.
Go figure...
So I think I will stick to keeping unique test script names between different projects. I have no other explanation.... Anyone can shed light on this? Please do so...
mocha
directly (not usingnodemon
), I had this suddenly on Windows despite runningnpm i
. I had to explicitly runnpm i -D mocha
again, then it worked. – Meekins