运行 ng build 时,我不断收到此错误。
我尝试删除 node_modules 以及全局 npm_cache 目录并重新安装。我发现这个问题的大多数答案都是几年前的,所以按照一种解决方案的建议降级打字稿版本不是一种选择。
我也尝试过使用 typescript 2.5.3 版,但失败并出现同样的错误。
我也有队友可以毫无问题地运行 ng build。
有什么建议么?
角度版本信息:
Angular CLI: 1.6.7
Node: 8.9.1
OS: win32 x64
Angular: 4.4.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular/cli: 1.6.7
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@ngtools/json-schema: 1.1.0
typescript: 2.3.4
webpack-sources: 1.0.2
webpack: 3.10.0
Package.json 信息:
{
"name": "jeweler-app",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\" --project src/tsconfig.json --type-check && tslint \"e2e/**/*.ts\" --project e2e/tsconfig.json --type-check",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"deploy": "ng build --base-href /jewelerapplication/ --deploy-url=/Content/jewelerapplication/",
"devTeamDeploy": "ng build --base-href /jewelerapplication/ --deploy-url=/Content/JewelerApplication/ --e=devtest --output-hashing bundles --aot false --extractCss false --output-path=C:/Nuget/JewelerApplication",
"teamdeploy": "ng build --base-href /jewelerapplication/ --deploy-url=/Content/JewelerApplication/ --prod --aot false --extractCss false --output-path=C:/Nuget/JewelerApplication",
"watch": "ng build --extractCss false --watch --base-href /jewelerapplication/ --deploy-url=/Content/jewelerapplication/"
},
"private": true,
"dependencies": {
"@angular/animations": "4.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-beta.5",
"angular2-pubsub": "~4.0.0",
"angular2-text-mask": "~8.0.0",
"bootstrap": "~4.0.0-beta",
"core-js": "~2.4.1",
"font-awesome": "~4.7.0",
"install": "~0.10.1",
"ng2-datepicker": "~1.8.3",
"ng2-page-scroll": "~4.0.0-beta.7",
"ng2-responsive": "~0.8.4",
"ng2-semantic-ui": "~0.9.6",
"npm": "~5.4.2",
"rxjs": "^5.4.2",
"simple-line-icons": "~2.4.1",
"text-mask-addons": "~3.5.1",
"webpack-sources": "~1.0.1",
"zone.js": "~0.8.9"
},
"devDependencies": {
"@angular/cli": "1.6.7",
"@angular/compiler": "4.4.3",
"@angular/compiler-cli": "4.4.3",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.68",
"codelyzer": "~3.0.0",
"jasmine-core": "2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.5.0",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-remap-istanbul": "~0.6.0",
"protractor": "~5.1.1",
"ts-node": "~3.0.2",
"tslint": "~5.0.0",
"typescript": "^2.3.4"
}
}
错误详情:
ERROR in Error: AppModule is not an NgModule
at _getNgModuleMetadata (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\compiler-cli\src\ngtools_impl.js:140:15)
at _extractLazyRoutesFromStaticModule (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\compiler-cli\src\ngtools_impl.js:109:26)
at Object.listLazyRoutesOfModule (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\compiler-cli\src\ngtools_impl.js:53:22)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\compiler-cli\src\ngtools_api.js:91:39)
at AotPlugin._getLazyRoutesFromNgtools (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\plugin.js:240:66)
at _donePromise.Promise.resolve.then.then.then.then.then (C:\Repository\Premier Designs\jewelerapplication\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\plugin.js:493:24)
at <anonymous>