当生产构建项目在angular 4.4.4上并且跟随错误时,出现以下错误。
警告:缺少字体大小为5113:8。忽略。
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/mnt/.local/share/Trash/files/front_end/src'
ERROR in Error: Cannot determine the module for class AddWebsiteAndCampaign in /home/mnt/.local/share/Trash/files/front_end/src/app/campaign/campaign-main/campaign-main.component.ts! Add AddWebsiteAndCampaign to the NgModule to fix it.
Cannot determine the module for class CompanyEditComponent in /home/mnt/.local/share/Trash/files/front_end/src/app/company/company-edit/company-edit.component.ts! Add CompanyEditComponent to the NgModule to fix it.
at syntaxError (/home/mnt/.local/share/Trash/files/front_end/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
at analyzeAndValidateNgModules (/home/mnt/.local/share/Trash/files/front_end/node_modules/@angular/compiler/bundles/compiler.umd.js:24306:15)
at AotCompiler.analyzeModulesAsync (/home/mnt/.local/share/Trash/files/front_end/node_modules/@angular/compiler/bundles/compiler.umd.js:23937:46)
at CodeGenerator.codegen (/home/mnt/.local/share/Trash/files/front_end/node_modules/@angular/compiler-cli/src/codegen.js:32:14)
at Function.NgTools_InternalApi_NG_2.codeGen (/home/mnt/.local/share/Trash/files/front_end/node_modules/@angular/compiler-cli/src/ngtools_api.js:73:30)
at _donePromise.Promise.resolve.then (/home/mnt/.local/share/Trash/files/front_end/node_modules/@ngtools/webpack/src/plugin.js:428:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
当我使用ng build --env = prod时,生成了build,但是build不是生产版本,但是当我按照角度文档ng build --prod使用命令时,发生了上述错误。 我正在使用ubuntu 18。
答案 0 :(得分:0)
所收到的错误表示您有几个未在任何模块中声明的组件(在错误消息中命名)。
如消息所示,您必须在模块中声明这些组件。
非生产构建有效的原因是因为它实际上并未编译所有内容-而是解释了一些代码,并且完成的检查还不完整。
答案 1 :(得分:0)
很难从这里调试,但是您可以这样做: