您的位置:首页 > Web前端 > Node.js

nodejs遇到问题汇总

2014-05-30 16:06 295 查看
1 
<span style="font-size:14px;">var connect = require('..');</span>

上面这句代码,放在一般文件里时错误的,找不到文件,但是方在项目得test文件下,用mocha调用就是对的,应该时mocha特有得require形式,加载项目根目录的index.js



<span style="font-size:14px;">"scripts": {
"test": "mocha --require test/support/env --reporter dot",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec"
}</span>

以上代码是在packag.json里的.用npm test会执行"test"对应得命令,就是"mocha --require test/support/env --reporter dot".
但是运行npm test-cov说找不到命令.需要使用npm run-script test-cov才会成功执行.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nodejs