你如何安装和运行Mocha,Node.jstesting模块? 安装后得到“mocha:command not found”
我很难让Mocha如预期的那样工作,而且我很乐意按照logging来说,但是似乎没有太多关于实际运行的文档。
我已经使用npm
(全局和本地)安装它,每当我运行它我得到:
$ mocha mocha: command not found
好吧,所以我觉得这不是我的PATH
,所以我试着直接运行它,
$ ./node_modules/mocha/bin/mocha execvp(): No such file or directory
最后,我试着打另一个bin
文件,
$ ./node_modules/mocha/bin/_mocha path.existsSync is deprecated. It is now called `fs.existsSync`. . ✔ 1 tests complete (1ms)
我怎样才能用一个命令执行我的testing? 誓言似乎让你,但我听说摩卡是更好的select,我似乎无法让它正常工作。
对于我在第三次尝试中得到的错误有什么想法?
编辑:
我在跑,
- Ubuntu 11.10 64位
- Node.js 0.7.5
- npm 1.1.8
- 摩卡0.14.1
- 应该是0.6.0
你不希望你的库testing失败,取决于机器设置(摩卡作为全球,全球摩卡版本等),使用本地摩卡,跨平台作品的方式是:
node node_modules/.bin/mocha
npm将别名放在您的依赖项中的所有二进制文件中。 最后,在运行一个npm脚本时,npm会自动将node_modules / .bin添加到PATH中,所以在你的package.json中你可以做到:
"scripts": { "test": "mocha" }
并用它来调用它
npm test
经过进一步阅读,并从上面的Linus G Thiel确认,我发现我只是不得不,
- 降级到Node.js 0.6.12
- 而且,
- 安装摩卡全球
- 将
./node_modules/.bin
添加到我的PATH