gpt4 book ai didi

angular - ngModuleType.ngModuleDef.id 未定义 - 导入 NguCarousel 模块时出现 Angular 8 问题

转载 作者:行者123 更新时间:2023-12-05 00:53:37 25 4
gpt4 key购买 nike

当我尝试导入 NguCarousel 模块时,我的应用程序中断,因为 ngModuleType.ngModuleDef 未定义。如果我注释掉 NguCarousel 模块的导入,该应用程序运行正常。我尝试过更改软件包的版本,但没有运气。目前我已经安装了 Angular 8 的 v1.5.5。

任何想法为什么这个模块缺少这个属性?

js 错误: enter image description here

package.json

{
"name": "webapi",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run WebApi:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "8.2.12",
"@angular/cdk": "^8.2.3",
"@angular/common": "8.2.12",
"@angular/compiler": "8.2.12",
"@angular/core": "8.2.12",
"@angular/forms": "8.2.12",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "8.2.12",
"@angular/platform-browser-dynamic": "8.2.12",
"@angular/platform-server": "8.2.12",
"@angular/router": "8.2.12",
"@babel/compat-data": "^7.8.0",
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@ngu/carousel": "^1.5.5",
"@nguniversal/module-map-ngfactory-loader": "8.1.1",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.4.1",
"core-js": "^3.3.3",
"echarts": "^4.9.0",
"font-awesome": "^4.7.0",
"hammerjs": "^2.0.8",
"jquery": "^3.4.1",
"ngx-echarts": "^5.1.2",
"ngx-spinner": "^9.0.2",
"oidc-client": "^1.9.1",
"popper.js": "^1.16.1",
"rxjs": "^6.5.3",
"zone.js": "0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.24",
"@angular/cli": "^8.3.14",
"@angular/compiler-cli": "8.2.12",
"@angular/language-service": "8.2.12",
"@types/jasmine": "~3.4.4",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~12.11.6",
"codelyzer": "^5.2.0",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^4.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"typescript": "3.5.3"
},
"resolutions": {
"@babel/preset-env": "7.5.5"
},
"optionalDependencies": {
"node-sass": "^4.12.0",
"protractor": "~5.4.2",
"ts-node": "~8.4.1",
"tslint": "~5.20.0"
}
}

app.module.ts

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AccountModule } from './account/account.module';
import { AccountRoutingModule } from './account/account.routing.module';
import { AppComponent } from './app.component';
import { AuthService } from './services/auth.service';
import { NguCarouselModule } from '@ngu/carousel';

@NgModule({
declarations: [
AppComponent,

],
imports: [
BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
NguCarouselModule,
BrowserAnimationsModule,
AccountModule,
AccountRoutingModule,
RouterModule.forRoot([
{ path: 'unauthorized', component: UnauthorizedComponent },
{ path: '**', redirectTo: '' }
])
],
providers: [
AuthService,
],
bootstrap: [AppComponent]
})
export class AppModule { }

最佳答案

我今天在相同的 Angular 版本 (v8) 上遇到了同样的错误。这是由于安装更高版本的 Angular Material (v12)引起的,当我注意到我忘记指定版本时,我使用 npm uninstall 命令卸载它,然后重新安装正确的版本。这是我发生错误时的情况。

我的问题的解决方案

  1. 关闭 vs 代码
  2. 转到文件资源管理器上的项目路径
  3. 删除 node_modules 文件夹
  4. 再次在 vs code 上打开项目
  5. 运行命令npm i

节点包管理器将为您重新安装正确版本的所有包,这应该可以解决问题。

关于angular - ngModuleType.ngModuleDef.id 未定义 - 导入 NguCarousel 模块时出现 Angular 8 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67562858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com