In my Node.js project I have a script in my package.json file that runs the tests using mocha like so:
"scripts": {
"test": "mocha --reporter list spec/*",
"test:cov": "istanbul cover _mocha -R spec && open coverage/lcov-report/index.html"
},
I just tried to run the test script on my Windows machine by running:
npm run test
and I get the following message:
Error: Cannot find module 'C:\Users\[User]\Projects\Leaflet-LightCluster\spec\setup'
I decided to test if it was an issue with mocha by installing mocha globally (i.e. npm install -g mocha) and when I run the same command that is contained in the "test" script everything runs and works fine.
At work I use a Mac and have never had this issue. In fact I can run the same npm command on the same project on my Mac and it works. I'm working on some personal projects on my personal Windows machine and therefore assume this is a Windows issue?
Can anyone verify that this is a Windows issue? Also has anyone encountered this issue and knows how to fix it?
Thanks in advance!
1 Answer 1
Here is the configuration I use in both windows and unix environment with mocha installed locally:
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec --full-trace --trace ./test/**/*.spec.js"
you can review it here Link through the config there is more complicated as I need to cover forked instances.