What should I do for this error: require('connect').json() is undefined

我只是一个虾纸丫 提交于 2019-12-08 06:01:18

问题


When I typed gulp test, I get this error: require('connect').json() is undefined.. What should I do?

The detail error message as following:

 tianjiedeMacBook-Pro:meiyanapp tianjie$ gulp test
 /Users/tianjie/meiyanruhua/meiyanapp/node_modules/karma/lib/middleware/runner.js:11
 var json = require('connect').json();
                               ^ TypeError: undefined is not a function
     at Object.<anonymous> (/Users/tianjie/meiyanruhua/meiyanapp/node_modules/karma/lib/middleware/runner.js:11:31)
     at Module._compile (module.js:460:26)
     at Object.Module._extensions..js (module.js:478:10)
     at Module.load (module.js:355:32)
     at Function.Module._load (module.js:310:12)
     at Module.require (module.js:365:17)
     at require (module.js:384:17)
     at Object.<anonymous> (/Users/tianjie/meiyanruhua/meiyanapp/node_modules/karma/lib/web-server.js:7:24)
     at Module._compile (module.js:460:26)
     at Object.Module._extensions..js (module.js:478:10)

回答1:


I fixed that problem by:

npm install karma karma-jasmine karma-phantomjs-launcher --save-dev




回答2:


I dunno how that solve the problem ... Actually you are trying to use JSON() in connect module... Error shows json itself undefined and you are invoking using function ()... ?



来源:https://stackoverflow.com/questions/29664417/what-should-i-do-for-this-error-requireconnect-json-is-undefined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!