nodejs遇到问题汇总

 
<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才会成功执行.

发布了24 篇原创文章 · 获赞 3 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/u012787757/article/details/27684719