如何在windows node.js上运行Mochatesting(错误:找不到模块'C:\ cygdrive \ c \ Users)
我试图在Windows中运行一个应用程序,这个应用程序有一些摩卡testing。 我需要做。 我读过这个
摩卡要求make。 找不到在Windows上工作的make.exe
和这个
Node.js无法find模块 – 干扰Windows上的cygwin
我有在Github目录(cygwin目录结构之外)的应用程序,我安装了节点的Windows版本。
我试过使用PowerShell和设置别名build议,但我总是得到
> module.js:340 > throw err; > ^ Error: Cannot find module 'C:\cygdrive\c\Users\Nicola\AppData\Roaming\npm\node_modules\mocha\bin\mocha' > at Function.Module._resolveFilename (module.js:338:15) > at Function.Module._load (module.js:280:25) > at Module.runMain (module.js:487:10) > at process.startup.processNextTick.process._tickCallback (node.js:244:9) Makefile:5: recipe for target `test' failed make: *** > [test] Error 1
我在那个目录中安装了mocha(顺便说一句,为什么他不在node_modules子目录中寻找mocha?)。 问题似乎是C:\cygdrive\c\Users
部分我该如何解决?
我也尝试复制文件到我的家庭/目录下的cygwin,但我得到了
./node_modules/.bin/mocha: line 1: ../mocha/bin/mocha: No such file or directory Makefile:5: recipe for target `test' failed make: *** [test] Error 127
我该怎么办?
你应该使用msysgit – 它带有make。
我已经能够做到的最好的方法是首先在目录中安装mocha作为开发依赖(例如: npm install mocha --save-dev
)。 然后在package.json
中的npm test
命令中使用"test": "mocha"
。 这样,您就可以轻松地在CLI中运行npm test
进行标准化。 您现在可以在test/
目录中设置您的testing,或者只有一个简单的test.js
文件,以防止您只有几个testing运行。 另外,不要忘了有你的选项有一个mocha.opts
文件。 这应该工作,特别是如果你使用Git Bash(我试过Windows CMD,它也可以!)。
当你写“make test”,你收到这个:
./node_modules/.bin/mocha: line 1: ../mocha/bin/mocha: No such file or directory Makefile:5: recipe for target `test' failed make: *** [test] Error 127
这意味着你的项目中没有安装摩卡咖啡。 将mocha放入package.json并运行“npm install”:
{ "name": "appName" , "version": "0.0.1" , "private": true , "dependencies": { "mocha": "1.3.0" , "should": "1.0.0" } }
之后,我得到了我的testing在Windows上运行。