Reputation: 43
I practicing with Angular Tour of Heroes. Everything is fine until app-routing.module part. I got error after I following instruction add and edit app-routing.module.ts. Even I copy and paste all codes from final code review still get the same error.
Error: ./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js 43:12
Module parse failed: Identifier 'ɵngcc0' has already been declared (43: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 ɵngcc1 from '@angular/common';
> import * as ɵngcc0 from '@angular/core';
| import * as ɵngcc1 from '@angular/common';
| class RouterEvent {
package.json
{
"name": "angular-tour-of-heroes",
"version": "0.0.0",
"private": true,
"dependencies": {
"@angular/animations": "~11.2.4",
"@angular/common": "~11.2.4",
"@angular/compiler": "~11.2.4",
"@angular/core": "~11.2.4",
"@angular/forms": "^11.2.4",
"@angular/platform-browser": "~11.2.4",
"@angular/platform-browser-dynamic": "~11.2.4",
"@angular/router": "~11.2.4",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1102.3",
"@angular/cli": "~11.2.3",
"@angular/compiler-cli": "~11.2.4",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.1.5"
}
}
Upvotes: 2
Views: 2090
Reputation: 11
I have a workaround, It's not the proper solution but it works for me. Solution is to open file node_modules@angular\router_ivy_ngcc_\fesm2015\router.js
import * as ɵngcc0 from '@angular/core';
import * as ɵngcc1 from '@angular/common';
// import * as ɵngcc0 from '@angular/core';
// import * as ɵngcc1 from '@angular/common';
comment above two lines that are repeated. for me, it's lines 43 and 44. And restart your Angular Application. It will work!
Upvotes: 1
Reputation: 1
This problem´s so common in Angular. To resolve you should delete the folder "node_modules" and download this folder again just use this command "npm install" in the path of your application.
OR
You should import a RouteModule
like this:
import { RouterModule } from '@angular/router';
@NgModule({
imports: [
RouterModule
]
})
export class YourModule { }
terModule like this:
Upvotes: 0