首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >意外令牌非法-伊斯坦布尔测试_mocha

意外令牌非法-伊斯坦布尔测试_mocha
EN

Stack Overflow用户
提问于 2015-08-31 06:18:08
回答 1查看 1.7K关注 0票数 4

相关问题:

  1. 有人知道这个错误提到的module.js在哪里吗?

刚找到它,这里

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

???

在使用yogenerator-gulpplugin-coffee创建了一个项目之后,我立即遇到了命令npm test的问题。

基package.json "test"参数中列出的完整命令是

代码语言:javascript
复制
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...失败了,在_mocha.cmd文件中的'@'符号处出现了一个Unexpected token ILLEGAL错误:

代码语言:javascript
复制
$ 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:

代码语言:javascript
复制
{
  "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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-22 17:11:45

这是Windows机器上的一个问题,因为它无法以javascript的形式执行_mocha文件--正如您已经发现的那样。

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

代码语言:javascript
复制
istanbul test node_modules/mocha/bin/_mocha
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32304980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档