嗨,我是Angular2上的新手,当我尝试使用onicial angular.io网站上的示例运行npm test时,我收到此错误:
providers[name][0] is not a function
TypeError: providers[name][0] is not a function
at get (/Users/marcpursals/repos/..../node_modules/di/lib/injector.js:48:43)
at /Users/marcpursals/repos/...../node_modules/di/lib/injector.js:71:14
at Array.map (native)
at Injector.invoke (/Users/marcpursals/repos/...../node_modules/di/lib/injector.js:70:31)
at Server.start (/Users/marcpursals/repos/....node_modules/karma/lib/server.js:103:18)
at Promise (/Users/marcpursals/repos/..../node_modules/@angular/cli/tasks/test.js:35:25)
at Class.run (/Users/marcpursals/repos/..../node_modules/@angular/cli/tasks/test.js:15:16)
at Class.run (/Users/marcpursals/repos/....node_modules/@angular/cli/commands/test.js:99:25)
at Class.<anonymous> (/Users/marcpursals/repos/...../node_modules/@angular/cli/ember-cli/lib/models/command.js:134:17)
at process._tickCallback (internal/process/next_tick.js:103:7)
npm ERR! Test failed. See above for more details.
我使用angular 4.0.1,我的package.json是下一个:
"dependencies": {
"@angular/animations": "^4.0.1",
"@angular/common": "^4.0.1",
"@angular/compiler": "^4.0.1",
"@angular/compiler-cli": "^4.0.1",
"@angular/core": "^4.0.1",
"@angular/forms": "^4.0.1",
"@angular/http": "^4.0.1",
"@angular/material": "^2.0.0-beta.2",
"@angular/platform-browser": "^4.0.1",
"@angular/platform-browser-dynamic": "^4.0.1",
"@angular/platform-server": "^4.0.1",
"@angular/router": "^4.0.1",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.22",
"@types/d3": "^4.5.0",
"@types/jasmine": "^2.5.47",
"@types/lodash": "^4.14.50",
"@types/node": "^6.0.68",
"bootstrap": "^4.0.0-alpha.6",
...
"jasmine-spec-reporter": "^2.7.0",
"jquery": "^3.1.1",
...
"karma": "^1.5.0",
"karma-jasmine": "^1.1.0",
"karma-remap-istanbul": "^0.2.2",
"lodash": "^4.17.4",
....
"typescript": "^2.2.2",
"zone.js": "^0.8.4"
},
我试图谷歌但我没有找到线索。有没有人遇到同样的问题?
答案 0 :(得分:0)
检查您的karma.conf.js file
:在插件字段中,您应该直接指向karma,但@angular/cli/plugins