[英]Unexpected token ILLEGAL - istanbul test _mocha
module.js
this error talks about is? module.js
在哪里? load
function thinks the command was a '.js'
file. load
函数认为该命令是'.js'
文件。 How can i add extension handlers for '.cmd'
files? '.cmd'
文件添加扩展处理程序? ???
???
After creating a project using yo
and generator-gulpplugin-coffee
, I have run into an issue straight away with the command npm test
在使用
yo
和generator-gulpplugin-coffee
创建项目后,我立即遇到命令npm test
遇到问题
The full command listed in the base package.json "test"
paramater is 基本package.json
"test"
参数中列出的完整命令是
coffeelint gulpfile.coffee index.coffee test -f ./coffeelint.json && istanbul test _mocha --report lcovonly -- ./test/*.coffee --require coffee-script/register --reporter spec
The coffeelint works fine when i extract that command and run it, however the istanbul test _mocha...
fails with an Unexpected token ILLEGAL
error at the '@'
symbol in the _mocha.cmd
file: 当我提取该命令并运行它时,coffeelint工作正常,但
istanbul test _mocha...
在_mocha.cmd
文件中的'@'
符号处失败并出现Unexpected token ILLEGAL
错误:
$ npm test
> gulp-ember-template-compiler-2@0.0.0 test C:\Users\me\code\something
> coffeelint gulpfile.coffee index.coffee test -f ./coffeelint.json && istanbul test _mocha --report lcovonly -- ./test/*.coffee --require coffee-script/register --reporter spec
✓ gulpfile.coffee
✓ index.coffee
✓ test/main.coffee
✓ Ok! » 0 errors and 0 warnings in 3 files
C:\Users\me\code\something\node_modules\.bin\_mocha.CMD:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0
^
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at runFn (C:\Users\me\code\something\node_modules\istanbul\lib\command\common\run-with-cover.js:122:16)
at Object.run (C:\Users\me\code\something\node_modules\istanbul\lib\command\common\run-with-cover.js:254:9)
at TestCommand.Command.mix.run (C:\Users\me\code\something\node_modules\istanbul\lib\command\test.js:27:22)
at runCommand (C:\Users\me\code\something\node_modules\istanbul\lib\cli.js:78:19)
I've tried updating the libraries without success, here is my package.json: 我试过更新库没有成功,这是我的package.json:
{
"name": "dadeda",
"version": "0.0.0",
"description": "A plugin for gulp",
"keywords": [
"gulpplugin"
],
"repository": "me/dadeda",
"author": {
"name": "me",
"email": "me@there.com",
"url": "http://methere.com"
},
"files": [
"index.js"
],
"scripts": {
"prepublish": "gulp coffee --require coffee-script/register",
"test": "coffeelint gulpfile.coffee index.coffee test -f ./coffeelint.json && istanbul test _mocha --report lcovonly -- ./test/*.coffee --require coffee-script/register --reporter spec",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
},
"dependencies": {
"gulp-util": "^3.0.0",
"through2": "^0.6.1"
},
"devDependencies": {
"coffee-script": "^1.7.1",
"coffeelint": "^1.4.0",
"coveralls": "^2.8.0",
"del": "^1.2.1",
"gulp": "^3.5.2",
"gulp-coffee": "^2.1.2",
"istanbul": "^0.3.19",
"mocha": "^2.2.5",
"should": "^7.1.0"
},
"engines": {
"node": ">=0.10.0",
"npm": ">=1.3.7"
},
"license": "MIT"
}
I am using windows 10
, node 0.12.7
, npm 2.11.3
. 我使用的是
windows 10
, node 0.12.7
, npm 2.11.3
。
This is an issue on Windows machines as it can't execute the _mocha
file as javascript - as you have identified. 这是Windows机器上的一个问题,因为它无法像javascript那样执行
_mocha
文件 - 正如您所确定的那样。
The workaround is to pass the full path of the mocha file (as described in this issue ): 解决方法是传递mocha文件的完整路径(如本期所述 ):
istanbul test node_modules/mocha/bin/_mocha
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.