【发布时间】:2016-12-20 05:20:00
【问题描述】:
当我在 CMD 中运行示例 js 文件时。它显示错误,例如错误:找不到测试框架“mocha”。请帮我解决这个问题。
运行测试后出错:
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
Package.json:
{
"name": "macaca-test-sample",
"version": "0.1.0",
"description": "macaca-test-sample",
"keywords": [
"sample"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/xudafeng/macaca-test-sample.git"
},
"dependencies": {
"mocha": "^3.2.0"
},
"devDependencies": {
"jshint": "*",
"mocha": "^3.2.0",
"pre-commit": "1.1.1",
"webdriver-client": "~1.0.0"
},
"scripts": {
"test": "mocha",
"jshint": "make jshint"
},
"pre-commit": [
"jshint"
],
"homepage": "github.com/xudafeng/macaca-test-sample";,
"author": "xudafeng",
"email": "xudafeng@126.com",
"blog": "xdf.me";,
"license": "MIT"
}
【问题讨论】:
-
请分享代码。
-
安装摩卡
globally -
Shaharyar,我该怎么做
-
npm install --global mocha -
嗨 Shaharyar ,感谢它的帮助。但是再次运行它会显示另一个问题,例如 "basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ^^^^^^^ SyntaxError: missing ) 在模块的 Object.Module._extensions..js (module.js:416:10) 的 Module._compile (module.js:373:25) 的参数列表之后.load (module.js:343:32) 在 Function.Module._load (module.js:300:12) 在 Function.Module.runMain (module.js:441:10) 在启动时 (node.js:139: 18) 在 node.js:968:3"