gpt4 book ai didi

typescript - 错误 : NgModule is not an NgModule 中的错误

转载 作者:搜寻专家 更新时间:2023-10-30 21:59:43 25 4
gpt4 key购买 nike

它工作得很好,突然它在运行 ng serve 时开始给我下面的异常。我也没有做任何最近的升级或依赖项添加。

有人能帮我解决一下吗?

ERROR in Error: NgModule is not an NgModule
at _getNgModuleMetadata (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:140:15)
at _extractLazyRoutesFromStaticModule (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
at E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:129:27
at Array.reduce (native)
at _extractLazyRoutesFromStaticModule (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:128:10)
at includeLazyRouteAndSubRoutes (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:66:25)
at Array.reduce (native)
at includeLazyRouteAndSubRoutes (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:67:26)
at Array.reduce (native)
at Object.listLazyRoutesOfModule (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_impl.js:54:36)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (E:\Going-on\czc-admin-startupui\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (E:\Going-on\czc-admin-startupui\node_modules\@ngtools\webpack\src\plugin.js:207:44)
at _donePromise.Promise.resolve.then.then.then.then.then (E:\Going-on\czc-admin-startupui\node_modules\@ngtools\webpack\src\plugin.js:443:24)
at process._tickCallback (internal/process/next_tick.js:109:7)

webpack: Failed to compile.

我的 package.json 文件:

{
"name": "sb-admin-angular4-bootstrap4",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --ec=true",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.4.3",
"@angular/cli": "^1.4.3",
"@angular/common": "^4.4.3",
"@angular/compiler": "^4.4.3",
"@angular/compiler-cli": "^4.4.3",
"@angular/core": "^4.4.3",
"@angular/forms": "^4.4.3",
"@angular/http": "^4.4.3",
"@angular/platform-browser": "^4.4.3",
"@angular/platform-browser-dynamic": "^4.4.3",
"@angular/platform-server": "^4.4.3",
"@angular/router": "^4.4.3",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.25",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "0.0.3",
"@swimlane/ngx-datatable": "^9.3.0",
"angular2-datatable": "^0.6.0",
"angular2-multiselect-dropdown": "^1.2.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"ionicons": "^3.0.0",
"ng-block-ui": "^1.0.0-beta.15",
"ng-spin-kit": "^5.1.1",
"ng2-charts": "^1.5.0",
"rxjs": "^5.1.0",
"typescript": "^2.3.4",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^1.4.3",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}

我卸载、安装并再次尝试,但没有成功。尝试使用最新的 typescript 版本,但出现了一些其他异常,因此恢复了这些更改。

最佳答案

我犯了一个非常愚蠢的错误,将 NgModule 也添加到导入中。我刚刚删除它,然后这个问题就解决了。

import { NgModule } from '@angular/core';
import { AddBannerComponent } from './add-banner/add-banner.component';
import { BannerComponent } from './banner.component';
import { BannerRoutingModule } from './banner-routing.module';

@NgModule({
imports:[NgModule,BannerRoutingModule],
declarations:[AddBannerComponent,BannerComponent],
providers:[]
})
export class BannerModule{

}

已解决的代码:(从导入中删除了 NgModule)

import { NgModule } from '@angular/core';
import { AddBannerComponent } from './add-banner/add-banner.component';
import { BannerComponent } from './banner.component';
import { BannerRoutingModule } from './banner-routing.module';

@NgModule({
imports:[BannerRoutingModule],
declarations:[AddBannerComponent,BannerComponent],
providers:[]
})
export class BannerModule{

}

关于typescript - 错误 : NgModule is not an NgModule 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46438720/

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