nodejs遇到问题汇总

来源:互联网 发布:推荐位如何设计数据库 编辑:程序博客网 时间:2024/05/06 16:42
 
<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才会成功执行.

0 0
原创粉丝点击