简体   繁体   English

因果关系开始抛出useragent错误

[英]karma start throwing useragent error

I generated an app using yeoman by doing this in a folder called sw-front: 我通过在名为sw-front的文件夹中使用yeoman生成了一个应用程序:

yo angular

I installed karma like this 我这样安装业力

npm install -g karma
npm install -g karma-cli 

grunt serve works fine. 发牢骚服务效果很好。

karma -v throws the same error: mm-mac-2186:sw-front pkatepalli$ karma start 业力-v引发相同的错误:mm-mac-2186:sw-front pkatepalli $ 业力开始

module.js:340
    throw err;
          ^
Error: Cannot find module 'useragent'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/pkatepalli/Desktop/hands-on-angular/sw-front/node_modules/karma/lib/helper.js:4:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

module.js: module.js:

var Module = function() {
  var providers = [];

  this.factory = function(name, factory) {
    providers.push([name, 'factory', factory]);
    return this;
  };

  this.value = function(name, value) {
    providers.push([name, 'value', value]);
    return this;
  };

  this.type = function(name, type) {
    providers.push([name, 'type', type]);
    return this;
  };

  this.forEach = function(iterator) {
    providers.forEach(iterator);
  };
};

module.exports = Module;

mm-mac-2186:sw-front pkatepalli$ node -v mm-mac-2186:sw-front pkatepalli $节点-v

v0.10.28

mm-mac-2186:sw-front pkatepalli$ npm -v mm-mac-2186:sw-front pkatepalli $ npm -v

1.4.9

Try 尝试

npm cache clean

And removing the node_modules directory, if it exists, where you are running the commands form. 并删除运行命令表单的node_modules目录(如果存在)。

Then rebuild/reinstall 然后重建/重新安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM