"export 'ɵɵinject' was not found in '@angular/core'

半腔热情 提交于 2020-06-13 13:36:31

问题


I am getting this error when i tried to use MatToolBar in my angular app. In browser I get Uncaught TypeError: Object(...) is not a function and also get warnings in the console:

WARNING in ./node_modules/@angular/cdk/esm5/text-field.es5.js 146:151-159
"export 'ɵɵinject' was not found in '@angular/core'

WARNING in ./node_modules/@angular/cdk/esm5/a11y.es5.js 2324:206-214
"export 'ɵɵinject' was not found in '@angular/core'

How can I resolve this? On github it is a closed issue.


回答1:


So apparently after wasting 1 hour on the same issue, it seems your angular version and the material version should be same i.e if your angular CLI version is 7, you should use material version 7.

Just change the dependencies "@angular/material" and "@angular/cdk" version to "7.3.7" and change "@angular/animations" to "7.2.15"

Hope this solves your problem.




回答2:


The solution is to ensure all your packages are of the same versions.

Check Package.json file to find if the packages are on the same version.

Then in the command line use the command

ng update @angular/core

This should solve the problem




回答3:


I have resolved it, I just updated the dependency of angular material to 7 and angular version to 7.3.2 and it worked.




回答4:


I used @angular/core 7.x.x and I found a similar problem after I have installed npm install ngx-toastr --save. The ngx-toastr was version 11.x.x but the @angular/core was version 7.x.x

I have fixed it by updating the @angular/core and it updated to version 8.2.10

ng update @angular/core



回答5:


At first, I used below commands

npm install -S @angular/cdk @angular/animations
npm uninstall @angular/core
npm install -S @angular/core

Now, this solved this issue but then I faced this error

NullInjectorError: No provider for ViewportScroller

Solved that error by using the below command

ng update @angular/cli @angular/core



回答6:


This worked for me:

ng update @angular/core



回答7:


Just resolved this issue with Angular primeng. Just make sure @angular/cdk version and primeng version are same. It will work.

Also, make sure of there same versions as well. "@angular/cdk": "^7.3.7", "@angular/material": "^7.3.7",




回答8:


I have resolved it, we need to install proper npm plugin version corresponding to angular version.

For instance, if you are installing ngx-toastr then run; npm i ngx-toastr@10.1.0 for angular 8.x, 7.x, 6.x.

Check the support link for ngx-toastr version support for angular, which can be found here.




回答9:


WARNING in

./node_modules/@ng-select/ng-select/fesm2015/ng-select-ng-select.js

2560:52-70 "export 'ɵɵdefineInjectable' was not found in '@angular/core'

Just removed the ɵɵ from ɵɵdefineInjectable in the 3 occurrences in ./node_modules/@ng-select/ng-select/fesm2015/ng-select-ng-select.js

and it's working properly, thanks.



来源:https://stackoverflow.com/questions/56433781/export-%c9%b5%c9%b5inject-was-not-found-in-angular-core

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