I have a super simple Nodejs ES6 app. Not using Babel, not required.
On my Mac, the app runs, all tests run, and istanbul coverage works perfect.
On my Windows 10, the app runs, all tests run, but I get the below error when trying to use coverage.
Mac node -v v6.2.2
Windows node -v v6.3.1
Apologies, but I have no idea where to start. I've searched the web, one other person reported a similar problem on Windows here: https://github.com/ForbesLindesay/cmd-shim/issues/17 but I can't be sure this is the exact same root cause, I don't have the deep expertise.
Thank you in advance for any help in getting this working on Windows.
This is my command line:
node ./node_modules/.bin/istanbul cover ./node_modules/.bin/mocha
"devDependencies": {
"chai": "^3.5.0",
"istanbul": "^0.4.4",
"mocha": "^3.0.2",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0"
}
Error message:
\\Mac\Home\Documents\nodejs-es6-mocha\node_modules\.bin\istanbul:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (bootstrap_node.js:352:7)
at startup (bootstrap_node.js:144:9)
at bootstrap_node.js:467:3
Thank you,
Karl
I added a comment on https://github.com/ForbesLindesay/cmd-shim/issues/17 which I believe will solve the issue. For those who come here please refer to Usage on Windows section in the Istanbul readme.
@copenhas thank you very much. I'll test tonight, confirm, and close this.
@copenhas bingo!
This works for mocha: ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha
Thank you for your outstanding support and very quick response.
Best to you,
Karl
For those who uses Tape, the command should be :
istanbul cover node_modules/tape/bin/tape test_file.js
Just got the same error with tsc calling other module on windows 10, solved it by removing all shell(the ones without extension) files from node_modules/.bin/ folder -- it started to use *.cmd files.
"test": "node --inspect node_modules/.bin/cross-env API_HOST=url ember serve",
In my case when i removed node --inspect than its its work for me.
"test": "node_modules/.bin/cross-env API_HOST=url ember serve",
This solution works for Windows machine
I'd recommend using npx instead, you can run any executable under the node_modules/.bin directory with:
npx the-executable
Hi all, I am using a windows laptop and I am trying to debug mocha test files in nodejs application using vscode but I am getting this error same error as above when I try to debug the individual spec file in vscode any idea how can it be fixed? Do I need to make any changes in launch.json or package.json file?
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
Most helpful comment
@copenhas bingo!
This works for mocha: ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha
Thank you for your outstanding support and very quick response.
Best to you,
Karl