简体   繁体   中英

Error during running angular 13 app after migration

I just migrated my Angular application from version 9 to 13.

When running ng serve I have this result:

./src/main.ts - Error: Module build failed (from./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Symbol HttpClientModule declared in..../node_modules/@angular/common/http/http.d.ts is not exported from @angular/common/http (import into..../src/app/app.module.ts) at....\node_modules@ngtools\webpack\src\ivy\loader.js:77:18 at processTicksAndRejections (node:internal/process/task_queues:96:5)

./src/polyfills.ts - Error: Module build failed (from./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Symbol HttpClientModule declared in..../node_modules/@angular/common/http/http.d.ts is not exported from @angular/common/http (import into..../src/app/app.module.ts) at....\node_modules@ngtools\webpack\src\ivy\loader.js:77:18 at processTicksAndRejections (node:internal/process/task_queues:96:5)

Error: Inlining of fonts failed. An error has occurred while retrieving https://fonts.googleapis.com/icon?family=Material+Icons over the internet. connect ETIMEDOUT 142.250.74.234:443

this is my package.json:

{
  "name": "myApp",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.1.0",
    "@angular/cdk": "^13.1.1",
    "@angular/common": "~13.1.0",
    "@angular/compiler": "~13.1.0",
    "@angular/core": "~13.1.0",
    "@angular/forms": "~13.1.0",
    "@angular/material": "^13.1.1",
    "@angular/platform-browser": "~13.1.0",
    "@angular/platform-browser-dynamic": "~13.1.0",
    "@angular/router": "~13.1.0",
    "@ngx-translate/core": "^14.0.0",
    "@ngx-translate/http-loader": "^7.0.0",
    "bootstrap": "^4.4.1",
    "jquery": "^3.5.0",
    "moment": "^2.26.0",
    "ngx-mat-select-search": "^3.3.3",
    "ngx-translate-multi-http-loader": "^7.0.0",
    "prettier": "^2.0.5",
    "primeicons": "^5.0.0",
    "primeng": "^13.0.2",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.1.2",
    "@angular/cli": "~13.1.2",
    "@angular/compiler-cli": "~13.1.0",
    "@angular/language-service": "~13.1.0",
    "@types/jasmine": "~3.10.0",
    "@types/lodash": "^4.14.178",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.2",
    "jasmine-core": "~3.10.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.1.0",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "protractor": "^7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "tslint-html-report": "^2.0.4",
    "typescript": "~4.5.2",
    "typescript-tslint-plugin": "^0.5.5"
  }
}

app.module:

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent,
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
    MaterialModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    FormsModule ,
    NgxMatSelectSearchModule,
    TranslateModule.forRoot({
      loader: {
          provide: TranslateLoader,
          useFactory: HttpLoaderFactory,
          deps: [HttpClient]
      }
  })
  ],
  providers: [  
   {
    provide: MatPaginatorIntl,
    useClass: MatPaginatorI18n,
  }],
  bootstrap: [AppComponent],
  schemas: [
    CUSTOM_ELEMENTS_SCHEMA
  ],
})
export class AppModule { }

thank you for your help

I ran into this same error. In my case, there were 2 node_modules directories. Check the error message for main.ts vs polyfills.ts .

Since it looks like you replaced the names of your project directories with ... , if there are 2 node modules directories, deleting one should fix the problem.

In my case it was an angular workspace, where there was a node_modules folder at the root with a node_modules folder in one of the projects.

I fixed it by deleting the entire node_modules folder referenced in the error directly under main.ts

./src/main.ts - Error: Module build failed (from
./node_modules/@ngtools/webpack/src/ivy/index.js): 
Error: Symbol HttpClientModule declared in
..../node_modules/@angular/common/http/http.d.ts is not exported from

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM