Node: NPM run test (Karma) fails always in Windows

Created on 16 Aug 2016  路  2Comments  路  Source: nodejs/node

I'm opening this issue because:

Actual behavior

This is the test script that has been configured in package.json
"test": "node --max-old-space-size=4096 ./node_modules/.bin/karma start"
BUT WHEN i try to execute it, it always error.

:"ERROR"
case uname in
^^^^
SyntaxError: Unexpected token case
at Object.exports.runInThisContext (vm.js:76:16
at Module._compile (module.js:513:28)
at Object.Module._extensions..js (module.js:550
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

Please let me know what can be done.

I have the latest node js installed and working too !.

supporting information:

npm -v prints: 3.10.6
node -v prints:6.3.1
Windows, OS X, or Linux?: Windows -64
Thanks in advance

npm question

Most helpful comment

This happens because on Windows, npm doesn鈥檛 install symbolic links to the actual scripts in node_modules/.bin/, but instead creates .cmd files in that directory. When run as node ./node_modules/.bin/karma, node tries to read that .cmd file and execute it, but doesn鈥檛 understand it because it isn鈥檛 JS.

I am assuming this is from a package.json that is under your control. If you really need --max-old-space-size=4096, you are probably best off using a hardcoded path to the karma executable in your test script, i.e. something like node --max-old-space-size=4096 ./node_modules/karma/bin/karma start.

All 2 comments

This happens because on Windows, npm doesn鈥檛 install symbolic links to the actual scripts in node_modules/.bin/, but instead creates .cmd files in that directory. When run as node ./node_modules/.bin/karma, node tries to read that .cmd file and execute it, but doesn鈥檛 understand it because it isn鈥檛 JS.

I am assuming this is from a package.json that is under your control. If you really need --max-old-space-size=4096, you are probably best off using a hardcoded path to the karma executable in your test script, i.e. something like node --max-old-space-size=4096 ./node_modules/karma/bin/karma start.

Closing this because I see you already reported it both at https://github.com/karma-runner/karma/issues/2309 and https://github.com/npm/npm/issues/13674.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filipesilvaa picture filipesilvaa  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

dfahlander picture dfahlander  路  3Comments

cong88 picture cong88  路  3Comments

fanjunzhi picture fanjunzhi  路  3Comments