相关问题:
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...失败了,在_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)我尝试过更新库,但没有成功,下面是我的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。
发布于 2016-02-22 17:11:45
这是Windows机器上的一个问题,因为它无法以javascript的形式执行_mocha文件--正如您已经发现的那样。
解决方法是传递mocha文件的完整路径(如本期中所述):
istanbul test node_modules/mocha/bin/_mochahttps://stackoverflow.com/questions/32304980
复制相似问题