error TS1086: An accessor cannot be declared in an ambient context in Angular 9

后端 未结 7 1295
清酒与你
清酒与你 2021-02-03 18:14

I\'m learning Angular Material and I\'m getting this error when importing { MatButtonModule } from \"@angular/material/button\".

From what I read in other answers, it lo

相关标签:
7条回答
  • 2021-02-03 19:00

    First please check in module.ts file that in @NgModule all properties are only one time. If any of are more than one time then also this error come. Because I had also occur this error but in module.ts file entryComponents property were two time that's why I was getting this error. I resolved this error by removing one time entryComponents from @NgModule. So, I recommend that first you check it properly.

    0 讨论(0)
  • 2021-02-03 19:03

    These issue arise generally due to mismatch between @ngx-translate/core version and Angular .Before installing check compatible version of corresponding ngx_trnalsate/Core, @ngx-translate/http-loader and Angular at https://www.npmjs.com/package/@ngx-translate/core

    Eg: For Angular 6.X versions,

    npm install @ngx-translate/core@10 @ngx-translate/http-loader@3 rxjs --save
    

    Like as above, follow below command and rest of code part is common for all versions(Note: Version can obtain from( https://www.npmjs.com/package/@ngx-translate/core)

    npm install @ngx-translate/core@version @ngx-translate/http-loader@version rxjs --save
    
    0 讨论(0)
  • 2021-02-03 19:05

    Adding skipLibCheck: true in compilerOptions inside tsconfig.json file fixed my issue.

    "compilerOptions": {
       "skipLibCheck": true,
    },
    
    0 讨论(0)
  • 2021-02-03 19:14

    I had this problem but didn't have a version conflict in my package.json.

    My package-lock.json was somehow out of sync with package json though. Deleting and regenerating it worked for me.

    0 讨论(0)
  • 2021-02-03 19:15

    I solved the same issue by following steps:

    Check the angular version: Using command: ng version My angular version is: Angular CLI: 7.3.10

    After that I have support version of ngx bootstrap from the link: https://www.npmjs.com/package/ngx-bootstrap

    In package.json file update the version: "bootstrap": "^4.5.3", "@ng-bootstrap/ng-bootstrap": "^4.2.2",

    Now after updating package.json, use the command npm update

    After this use command ng serve and my error got resolved

    0 讨论(0)
  • 2021-02-03 19:16

    Just update your package

    command: npm i

    0 讨论(0)
提交回复
热议问题