意外的标记ILLEGAL - 伊斯坦布尔测试_mocha

时间:2015-08-31 06:18:08

标签: node.js npm mocha istanbul

相关问题:

  1. 有谁知道这个错误所涉及的module.js在哪里?
  2.   

    刚刚找到它here

    1. 看起来module.js load函数认为命令是'.js'文件。如何为'.cmd'文件添加扩展处理程序?
    2.   

      ???

      使用yogenerator-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错误时失败:< / p>

      $ 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 10node 0.12.7npm 2.11.3

1 个答案:

答案 0 :(得分:7)

这是Windows计算机上的一个问题,因为它无法像javascript那样执行_mocha文件。

解决方法是传递mocha文件的完整路径(如this issue中所述):

istanbul test node_modules/mocha/bin/_mocha