I am trying to understand what I am doing wrong in this instance. I have a Node.js project with the following in my package.json
"scripts": {
"test": "mocha --recursive ./src/setup/*.js ./test/**/*.js"
},
"dependencies": {
"mocha": "^2.2.5"
}
When I run 'npm test' the mocha tests are run correctly:
$ npm test (successful run)
However when I try to just run the mocha command I have there in my package.json
$ mocha --recursive ./src/setup/*.js ./test/**/*.js"
This errors with:
-sh: mocha: command not found
I do not have mocha globally installed, I only have installed it via npm to this specific project.
If I install mocha globally then it works. Why doesn't it work when I have simply have mocha installed in the current directory's node_modules, yet it does with 'npm test'?
npm scripts automatically add mocha to the PATH:
If you depend on modules that define executable scripts, like test suites, then those executables will be added to the PATH for executing the scripts.
https://docs.npmjs.com/misc/scripts#path
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