我的应用程序使用ng serve
正常运行,但在使用ng build --prod
构建之后我得到了这个例外:
vendor.350ea18ab78ed7d28861.bundle.js:1 ERROR Error: No provider for e!
at E (vendor.350ea18ab78ed7d28861.bundle.js:1)
at x (vendor.350ea18ab78ed7d28861.bundle.js:1)
at t._throwOrNull (vendor.350ea18ab78ed7d28861.bundle.js:1)
at t._getByKeyDefault (vendor.350ea18ab78ed7d28861.bundle.js:1)
at t._getByKey (vendor.350ea18ab78ed7d28861.bundle.js:1)
at t.get (vendor.350ea18ab78ed7d28861.bundle.js:1)
at Ue (vendor.350ea18ab78ed7d28861.bundle.js:1)
at t.get (vendor.350ea18ab78ed7d28861.bundle.js:1)
at Sn (vendor.350ea18ab78ed7d28861.bundle.js:1)
at En (vendor.350ea18ab78ed7d28861.bundle.js:1)
问题是我无法找到此异常的来源,我不知道它来自何处!
我正在使用Angular版本4和ng CLI版本1.4.2,这是我的package.json文件:
"dependencies": {
"@agm/core": "^1.0.0-beta.1",
"@angular/animations": "^4.4.1",
"@angular/common": "^4.4.1",
"@angular/compiler": "^4.4.1",
"@angular/core": "^4.4.1",
"@angular/forms": "^4.4.1",
"@angular/http": "^4.4.1",
"@angular/platform-browser": "^4.4.1",
"@angular/platform-browser-dynamic": "^4.4.1",
"@angular/router": "^4.4.1",
"core-js": "^2.5.1",
"ngx-color-picker": "^4.5.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/cli": "^1.4.2",
"@angular/compiler-cli": "^4.4.1",
"@angular/language-service": "^4.4.1",
"@types/jasmine": "^2.6.0",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^6.0.88",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
我该怎么办?
答案 0 :(得分:0)
我找到了解决方案,这是版本问题
更新到4.4.3之后,现在一切正常
这是我的package.json现在:
{
"name": "my-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@agm/core": "^1.0.0-beta.1",
"@angular/animations": "^4.4.3",
"@angular/common": "^4.4.3",
"@angular/compiler": "^4.4.3",
"@angular/core": "^4.4.3",
"@angular/forms": "^4.4.3",
"@angular/http": "^4.4.3",
"@angular/platform-browser": "^4.4.3",
"@angular/platform-browser-dynamic": "^4.4.3",
"@angular/router": "^4.4.3",
"core-js": "^2.5.1",
"ngx-color-picker": "^4.5.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.17"
},
"devDependencies": {
"@angular/cli": "^1.6.0",
"@angular/compiler-cli": "^4.4.3",
"@angular/language-service": "^4.4.3",
"@types/jasmine": "^2.6.0",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^6.0.88",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "^2.6.2",
"webpack": "^3.10.0"
}
}