意外的令牌非法 - 伊斯坦布尔测试_mocha
Unexpected token ILLEGAL - istanbul test _mocha
相关问题:
- 有谁知道
module.js
这个错误所说的在哪里?
just found it here
- 看起来 module.js
load
函数认为该命令是一个 '.js'
文件。我如何为 '.cmd'
个文件添加扩展处理程序?
???
在使用 yo
和 generator-gulpplugin-coffee
创建项目后,我 运行 直接使用命令 npm test
遇到了问题
基本 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
当我提取该命令并 运行 它时,coffeelint 工作正常,但是 istanbul test _mocha...
失败并在 '@'
符号处出现 Unexpected token ILLEGAL
错误 _mocha.cmd
文件:
$ 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)
我试过更新库但没有成功,这是我的 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"
}
我正在使用 windows 10
、node 0.12.7
、npm 2.11.3
。
这是 Windows 机器上的一个问题,因为它无法像 javascript 一样执行 _mocha
文件 - 正如您所确定的那样。
解决方法是传递 mocha 文件的完整路径(如 this issue 中所述):
istanbul test node_modules/mocha/bin/_mocha
相关问题:
- 有谁知道
module.js
这个错误所说的在哪里?
just found it here
- 看起来 module.js
load
函数认为该命令是一个'.js'
文件。我如何为'.cmd'
个文件添加扩展处理程序?
???
在使用 yo
和 generator-gulpplugin-coffee
创建项目后,我 运行 直接使用命令 npm test
基本 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
当我提取该命令并 运行 它时,coffeelint 工作正常,但是 istanbul test _mocha...
失败并在 '@'
符号处出现 Unexpected token ILLEGAL
错误 _mocha.cmd
文件:
$ 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)
我试过更新库但没有成功,这是我的 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"
}
我正在使用 windows 10
、node 0.12.7
、npm 2.11.3
。
这是 Windows 机器上的一个问题,因为它无法像 javascript 一样执行 _mocha
文件 - 正如您所确定的那样。
解决方法是传递 mocha 文件的完整路径(如 this issue 中所述):
istanbul test node_modules/mocha/bin/_mocha