Error NG1006: Two incompatible decorators on class
See original GitHub issueWhich @angular/* package(s) are the source of the bug?
forms
Is this a regression?
No
Description
I have an issue when compiling my project I googled the error and tried some of the things which were suggested to other people, but nothing worked.
I can’t figure out what’s wrong. can anyone help me out here? Here is my package.json file :
{
"name": "book-store",
"version": "1.0.0",
"engines": {
"node": "12.16.1",
"npm": "6.14.5"
},
"scripts": {
"ng": "ng",
"heroku-postbuild": "ng build --prod",
"start": "node server.js",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^12.0.0-next.6",
"@angular/cdk": "^11.2.6",
"@angular/common": "^12.0.0-next.6",
"@angular/compiler": "^12.0.0-next.6",
"@angular/core": "^12.0.0-next.6",
"@angular/flex-layout": "^9.0.0-beta.31",
"@angular/forms": "^12.2.16",
"@angular/material": "^11.2.6",
"@angular/platform-browser": "^12.0.0-next.6",
"@angular/platform-browser-dynamic": "^12.0.0-next.6",
"@angular/router": "^12.0.0-next.6",
"@ng-bootstrap/ng-bootstrap": "^12.0.2",
"@ngtools/webpack": "^9.1.15",
"bootstrap": "^5.1.3",
"express": "^4.17.1",
"path": "^0.12.7",
"rxjs": "~6.6.7",
"tslib": "^1.14.1",
"typescript": "~4.2.3",
"undo": "^0.1.4",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1102.6",
"@angular/cli": "^11.2.6",
"@angular/compiler-cli": "^12.0.0-next.6",
"@angular/language-service": "^12.0.0-next.6",
"@types/jasmine": "^3.6.9",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.20.7",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^5.2.3",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "^7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.3"
}
}
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
PS C:\Users\hasna\Downloads\A La Marocaine git - Copie\ALaMarocaineFinal\frontend\src\app> ng serve
Compiling @angular/forms : es2015 as esm2015
An unhandled exception occurred: Failed to compile entry-point @angular/forms (`es2015` as esm2015) due to compilation errors:
../../node_modules/@angular/forms/fesm2015/forms.js:6219:1 - error NG1006: Two incompatible decorators on class
6219 class MaxValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6220 constructor() {
~~~~~~~~~~~~~~~~~~~
...
6237 }
~~~~~
6238 }
~
../../node_modules/@angular/forms/fesm2015/forms.js:6279:1 - error NG1006: Two incompatible decorators on class
6279 class MinValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6280 constructor() {
~~~~~~~~~~~~~~~~~~~
...
6297 }
~~~~~
6298 }
~
../../node_modules/@angular/forms/fesm2015/forms.js:6758:31 - error NG6001: The class 'MinValidator' is listed in the declarations of the NgModule 'ɵInternalFormsSharedModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.
6758 declarations: SHARED_FORM_DIRECTIVES,
~~~~~~~~~~~~~~~~~~~~~~
../../node_modules/@angular/forms/fesm2015/forms.js:6279:7
6279 class MinValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~
'MinValidator' is declared here.
../../node_modules/@angular/forms/fesm2015/forms.js:6758:31 - error NG6001: The class 'MaxValidator' is listed in the declarations of the NgModule 'ɵInternalFormsSharedModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.
6758 declarations: SHARED_FORM_DIRECTIVES,
~~~~~~~~~~~~~~~~~~~~~~
../../node_modules/@angular/forms/fesm2015/forms.js:6219:7
6219 class MaxValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~
'MaxValidator' is declared here.
../../node_modules/@angular/forms/fesm2015/forms.js:6279:7 - error NG6003: Appears in the NgModule.exports of ɵInternalFormsSharedModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.
Is it missing an Angular annotation?
6279 class MinValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~
../../node_modules/@angular/forms/fesm2015/forms.js:6219:7 - error NG6003: Appears in the NgModule.exports of ɵInternalFormsSharedModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.
Is it missing an Angular annotation?
6219 class MaxValidator extends AbstractValidatorDirective {
~~~~~~~~~~~~
../../node_modules/@angular/forms/fesm2015/forms.js:6754:7 - error NG6003: Appears in the NgModule.exports of FormsModule, but itself has errors
6754 class ɵInternalFormsSharedModule {
~~~~~~~~~~~~~~~~~~~~~~~~~~
../../node_modules/@angular/forms/fesm2015/forms.js:6754:7 - error NG6003: Appears in the NgModule.exports of ReactiveFormsModule, but itself has errors
6754 class ɵInternalFormsSharedModule {
~~~~~~~~~~~~~~~~~~~~~~~~~~
See "C:\Users\hasna\AppData\Local\Temp\ng-xVPSqM\angular-errors.log" for further details.
Please provide the environment you discovered this bug in (run ng version
)
Angular CLI: 13.3.0
Node: 16.14.2
Package Manager: npm 6.14.17
OS: win32 x64
Angular: undefined
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1303.0 (cli-only)
@angular-devkit/core 13.3.0 (cli-only)
@angular-devkit/schematics 13.3.0 (cli-only)
@schematics/angular 13.3.0 (cli-only)
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error NG1006: Two incompatible decorators on class
Here is what I did: The source of my problem: I had misaligned versions listed in my package.json file, so I deleted the...
Read more >Error NG1006: Two incompatible decorators on class-angular.js
The source of my problem: I had misaligned versions listed in my package.json file, so I deleted the node_modules folder and the package.json...
Read more >[Solved] Error NG1006: Two incompatible decorators on class
Hasnae Bouhmady Asks: Error NG1006: Two incompatible decorators on class I am having an issue when compiling my project: PS C:\Users\hasna\Downloads\A...
Read more >[Ivy] Incompatibility of Esm2015ReflectionHost with libraries ...
bug report Affected Package The issue is caused by @angular/compiler-cli Is this a ... NG1006: Two incompatible decorators on class ...
Read more >Missing @Directive()/@Component() decorator migration
This migration adds an empty @Directive() decorator to undecorated base classes that: Use Angular features; Are extended by directives or components.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Other than that this isn’t actionable for us, so I’m going to close this. Feel free to follow up below though.
I’d suggest clearing
node_modules
and reinstalling packages, as this seems like a transient issue. I’d also recommend to go over the project’s dependencies as the currently listed versions inpackage.json
are very misaligned; for example the Angular framework packages, the CLI and Material/CDK need to all be the same major version, but they’re a mix of 12, 11 and 9. If the project structure is not too complicated you may want to consider creating a new project from scratch and moving your existing code.