[Fixed] Can not use Angular FormsModule because of an error


Every time I am importing FormsModule from ‘@angular/forms’, it gives me the following error:

Error: ./node_modules/@angular/forms/__ivy_ngcc__/fesm2015/forms.js 27:12
Module parse failed: Identifier 'ɵngcc0' has already been declared (27:12)
File was processed with these loaders:
 * ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
 * ./node_modules/@ngtools/webpack/src/ivy/index.js
You may need an additional loader to handle the result of these loaders.
|  */
| import * as ɵngcc0 from '@angular/core';
> import * as ɵngcc0 from '@angular/core';
| const NG_VALUE_ACCESSOR = new InjectionToken('NgValueAccessor');

Here is my piece of code:

import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }

An interesting point in this question is that if I am not including FormsModule in an imports list, code works just fine, but when it is in the list, it causes problems. Simple importing FormsModule seems not to be the problem.

How can I solve it?


I had to run npm ci and after that npm install again. It was enough, it works.

Leave a Reply

(*) Required, Your email will not be published