我知道这是一个已经被问到的问题,我已经尝试了所有可能的发现。仍然无法破解。任何帮助表示赞赏。
错误:
ERROR in ./src/main.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (C:\WORK\folder\folder\folder\node_modules\@ngtools\webpack\src\loader.js:33:15)
@ multi ./src/main.ts
ERROR in ./src/polyfills.ts
Module build failed: Error: Angular Compiler was detected but it was an instance of the wrong class.
This likely means you have several @ngtools/webpack packages installed. You can check this with `npm ls @ngtools/webpack`, and then remove the extra copies.
at Object.ngcLoader (C:\WORK\folder\folder\folder\node_modules\@ngtools\webpack\src\loader.js:33:15)
@ multi ./src/polyfills.ts
ERROR in Error: No NgModule metadata found for 'AppModule'.
at NgModuleResolver.resolve (C:\WORK\folder\folder\folder\node_modules\@angular\compiler\bundles\compiler.umd.js:20291:23)
at CompileMetadataResolver.getNgModuleMetadata (C:\WORK\folder\folder\folder\node_modules\@angular\compiler\bundles\compiler.umd.js:15244:60)
at visitLazyRoute (C:\WORK\folder\folder\folder\node_modules\@angular\compiler\bundles\compiler.umd.js:31182:104)
at AotCompiler.listLazyRoutes (C:\WORK\folder\folder\folder\node_modules\@angular\compiler\bundles\compiler.umd.js:31150:20)
at AngularCompilerProgram.listLazyRoutes (C:\WORK\folder\folder\folder\node_modules\@angular\compiler-cli\src\transformers\program.js:228:34)
at Function.NgTools_InternalApi_NG_2.listLazyRoutes (C:\WORK\folder\folder\folder\node_modules\@angular\compiler-cli\src\ngtools_api.js:47:40)
at AngularCompilerPlugin._getLazyRoutesFromNgtools (C:\WORK\folder\folder\folder\node_modules\@angular\cli\node_modules\@ngtools\webpack\src\ang
配置:
Angular CLI: 1.7.0-beta.2
Node: 8.9.4
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, router
@angular/cli: 1.7.0-beta.2
@angular/compiler-cli: 6.1.3
@angular/language-service: 6.1.3
@angular-devkit/architect: 0.8.0-beta.3
@angular-devkit/build-angular: 0.8.0-beta.3
@angular-devkit/build-optimizer: 0.8.0-beta.3
@angular-devkit/build-webpack: 0.8.0-beta.3
@angular-devkit/core: 0.8.0-beta.3
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 6.2.0-beta.3
@schematics/angular: 0.1.17
@schematics/package-update: 0.0.7
typescript: 2.9.2
webpack: 4.16.5
Package.json
{
"name": "app1",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.9",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@progress/kendo-angular-buttons": "^3.0.4",
"@progress/kendo-angular-dateinputs": "^2.2.0",
"@progress/kendo-angular-dropdowns": "^2.1.0",
"@progress/kendo-angular-excel-export": "^1.0.7",
"@progress/kendo-angular-grid": "^2.1.2",
"@progress/kendo-angular-inputs": "^2.2.0",
"@progress/kendo-angular-intl": "^1.3.2",
"@progress/kendo-angular-l10n": "^1.0.7",
"@progress/kendo-data-query": "^1.2.0",
"@progress/kendo-drawing": "^1.5.1",
"@progress/kendo-ui": "^2018.2.620",
"angular-font-awesome": "^3.1.2",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0-beta.0",
"@angular/cli": "1.7.0-beta.2",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
}
npm列表-global --depth 0
+-- @angular/cli@1.6.8
+-- angular-1.6-cli@1.6.3
+-- gulp@3.9.1
+-- gulp-cli@2.0.1
+-- typescript@2.9.2
+-- uglify-js@3.3.24
+-- webpack@4.16.2
+-- webpack-cli@3.1.0
`-- webpack-dev-server@3.1.5
我尝试了所有可能的想法
这里缺少的任何帮助将不胜感激。
---------------------------------
经过大量研究,我可以通过将package.json更改为以下内容来解决此问题
{
"name": "app1",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/cdk": "^5.2.4",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/material": "^5.2.4",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"@progress/kendo-angular-buttons": "^3.0.4",
"@progress/kendo-angular-dateinputs": "^2.2.0",
"@progress/kendo-angular-dropdowns": "^2.1.0",
"@progress/kendo-angular-excel-export": "^1.0.7",
"@progress/kendo-angular-grid": "^2.1.2",
"@progress/kendo-angular-inputs": "^2.2.0",
"@progress/kendo-angular-intl": "^1.3.2",
"@progress/kendo-angular-l10n": "^1.0.7",
"@progress/kendo-data-query": "^1.2.0",
"@progress/kendo-drawing": "^1.5.1",
"@progress/kendo-ui": "^2018.2.620",
"angular-font-awesome": "^3.1.2",
"core-js": "^2.4.1",
"ng2-tooltip": "0.0.7",
"rxjs": "^5.5.6",
"webpack": "^2.5.1",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~1.7.2",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3"
}
}
但是仍然有另一个问题说。
ERROR in No NgModule metadata found for 'AppModule'.
任何人都可以在这里提供帮助。任何帮助都非常有用
答案 0 :(得分:4)
我遇到了同样的问题,并通过以下方式解决了
1)将软件包@ngtools/webpack
更新到最新版本
2)删除node_modules
,package-lock.json
并运行干净的npm install
答案 1 :(得分:0)
您的项目的依赖项可能会发生冲突。例如@angular/compiler-cli
的版本为6.1.0,而@angular/core
的版本仍为5.20。尝试将@angular/compiler-cli
降级为5.x或升级到角度6(https://update.angular.io/)
答案 2 :(得分:0)
我删除了@ngtools\webpack
文件夹和package-lock.json
,然后运行yarn
(不是 npm install
或npm update
)。我不确定这是否是个好方法,但是对我有用。
答案 3 :(得分:0)
这个对我有用 npm卸载@ angular-devkit / build-angular
npm install @ angular-devkit / build-angular -D
答案 4 :(得分:0)
这似乎是最好的解决方案,为我工作了两次。运行以下命令-
npm重复数据删除
您将能够看到一些审核详细信息。要修复,只需运行-
npm审核修复程序
,如果有必要(错误仍然存在),请按照以下步骤运行-
npm审核修复程序--force
这将对所有重复的软件包进行重复数据删除,并同时修复其版本号。
希望这会有所帮助!