简体   繁体   English

找不到Angular 6的“ Fy”的NgModule元数据

[英]No NgModule metadata found for 'Fy', Angular 6

This question is similar to 这个问题类似于

No NgModule metadata found for 'AppModule'" after Upgrade to Angular 5.1.0 and AngularCli 1.6.0 升级到Angular 5.1.0和AngularCli 1.6.0后,找不到“ AppModule”的NgModule元数据

Or, many of the other "No NgModule metadata found for 'AppModule'" questions. 或者,还有许多其他“找不到'AppModule'的NgModule元数据”问题。

But, seems to be more specific. 但是,似乎更具体。 I only get the following error when I publish to a web server. 发布到Web服务器时,只会出现以下错误。 The program runs fine when published to my local machine and when built in development mode. 当发布到我的本地计算机上并在开发模式下构建时,该程序运行良好。

Instead of no metadata found for 'AppModule', it reports no metadata found for 'Cm' or 'Fy'. 它没有报告未找到“ Cm”或“ Fy”的元数据,而不是未找到“ AppModule”的元数据。

Other people were saying that might be an issue with Webpack, but I couldn't find any solution. 其他人说这可能是Webpack的问题,但我找不到任何解决方案。 I've tried updating my npm packages, deleting them all, clearing the cache, and reinstalling. 我试过更新我的npm软件包,删除所有软件包,清除缓存,然后重新安装。



    GET https://dev.celinainsurance.com/styles.52c5d139a2a0d528a6bd.css 404 ()
    3 GET https://dev.celinainsurance.com/polyfills.16c7192dd87d7bd6ba49.js 404 ()
    main.d7aa191a672411cff0f3.js:1 Uncaught Error: No NgModule metadata found for 'Fy'.
        at e.resolve (main.d7aa191a672411cff0f3.js:1)
        at e.getNgModuleMetadata (main.d7aa191a672411cff0f3.js:1)
        at e._loadModules (main.d7aa191a672411cff0f3.js:1)
        at e._compileModuleAndComponents (main.d7aa191a672411cff0f3.js:1)
        at e.compileModuleAsync (main.d7aa191a672411cff0f3.js:1)
        at e.compileModuleAsync (main.d7aa191a672411cff0f3.js:1)
        at e.bootstrapModule (main.d7aa191a672411cff0f3.js:1)
        at Object.zUnb (main.d7aa191a672411cff0f3.js:1)
        at p (runtime.a66f828dca56eeb90e02.js:1)
        at Object.4 (main.d7aa191a672411cff0f3.js:1)
    e.resolve @ main.d7aa191a672411cff0f3.js:1
    e.getNgModuleMetadata @ main.d7aa191a672411cff0f3.js:1
    e._loadModules @ main.d7aa191a672411cff0f3.js:1
    e._compileModuleAndComponents @ main.d7aa191a672411cff0f3.js:1
    e.compileModuleAsync @ main.d7aa191a672411cff0f3.js:1
    e.compileModuleAsync @ main.d7aa191a672411cff0f3.js:1
    e.bootstrapModule @ main.d7aa191a672411cff0f3.js:1
    zUnb @ main.d7aa191a672411cff0f3.js:1
    p @ runtime.a66f828dca56eeb90e02.js:1
    4 @ main.d7aa191a672411cff0f3.js:1
    p @ runtime.a66f828dca56eeb90e02.js:1
    n @ runtime.a66f828dca56eeb90e02.js:1
    e @ runtime.a66f828dca56eeb90e02.js:1
    (anonymous) @ main.d7aa191a672411cff0f3.js:1

Any help would be greatly appreciated. 任何帮助将不胜感激。 Let me know if you need to see more code. 让我知道是否需要查看更多代码。 Thanks! 谢谢!

I believe I found my error. 我相信我发现了我的错误。 I decided to create a new angular project and to repetitively publish it as I added npm packages, to see when the error would occur. 我决定创建一个新的angular项目,并在添加npm软件包时重复发布它,以查看何时发生错误。 When I looked up a tutorial on how to migrate my new project from angular 5 to 6, I followed the steps found here: http://www.talkingdotnet.com/upgrade-angular-5-app-angular-6-visual-studio-2017/ 当我查看有关如何将新项目从角度5迁移到角度6的教程时,我遵循此处找到的步骤: http : //www.talkingdotnet.com/upgrade-angular-5-app-angular-6-visual-工作室-2017 /

When I compared my old project to the working new one, I noticed two major differences. 当我将旧项目与正在运行的新项目进行比较时,我注意到了两个主要区别。 One was that when I had migrated my old project to angular 6, I had missed this step: 其中之一是,当我将旧项目迁移到6号角时,我错过了这一步:

"Once this is done, remove rxjs-compat. This package is required to get backwards compatibility with RxJS previous to version 6. But, it is no longer required now, so let's remove it using the following command: " “一旦完成,请删除rxjs-compat。此软件包是与版本6之前的RxJS向后兼容所必需的。但是,现在不再需要此软件包,因此,请使用以下命令将其删除:”

npm uninstall rxjs-compat

-- TalkingDotNet -TalkingDotNet

I believe that was the major cause of the error. 我认为这是导致错误的主要原因。 The other major difference I found was a segment of unnecessary code which probably didn't cause the problem, but I'm going to mention anyway just in case. 我发现的另一个主要区别是一段不必要的代码,这可能不会引起问题,但无论如何,我还是要提一下。

I had accidentally duplicated this line of code, in my main.ts file. 我不小心在main.ts文件中复制了这一行代码。

platformBrowserDynamic().bootstrapModule(AppModule)

platformBrowserDynamic(providers).bootstrapModule(AppModule)
  .catch(err => console.log(err));

The lines of code looked slightly different, so I hadn't noticed the duplication. 代码行看起来略有不同,所以我没有注意到重复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM