Angular 9 : Value at position X in the NgModule. 导入不是引用

标签 angular deeplink angular-cli-v9

我将 Angular 应用程序从 v8 升级到 v9。该项目使用 Angular 8 和 moment.js 导入自定义 UI 库。

当我构建它时:

  • 它会生成一个警告:
  • WARNING in Entry point '@myLib/catalogue' contains deep imports into
     '/Users/xyz/Projects/forms-frontend/node_modules/moment/locale/de'.
    This is probably not a problem, but may cause the compilation of entry points to be out of order.
    

    @myLib/catalogue.js库文件(在 node_modules 文件夹内),moment.js DE 语言环境导入如下:
    import 'moment/locale/de';
    

  • 也会触发编译错误:
  • ERROR in Failed to compile entry-point @myLib/catalogue (es2015 as esm2015) due to compilation errors:
    node_modules/@myLib/catalogue/fesm2015/catalogue.js:213:26 - error NG1010: Value at position 2 in the NgModule.imports of FormInputModule is not a reference: [object Object]
    
    213                 imports: [
                                 ~
    214                     CommonModule,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ... 
    219                     TranslateModule
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    220                 ],
        ~~~~~~~~~~~~~~~~~
    

    警告的文本​​似乎准确地解释了编译错误,其中位置(在本例中为 2)超出了导入数组的范围。

    我看过不同的文章/github issues关于深层链接,但没有有效的解决方案。

    最佳答案

    您可能使用过 npm i 并且编辑器可能无法正确生成构建。尝试重新启动编辑器。重新启动对我有用。我正在使用 VSCode

    关于Angular 9 : Value at position X in the NgModule. 导入不是引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60726180/

    相关文章:

    angular - 为什么使用 Angular2 构建的应用程序如此沉重?

    node.js - 如何在 Angular 6 中将联系表单详细信息发送到电子邮件?

    javascript - 过滤并比较 typescript 中的两个数组与条件

    javascript - Angular 4 + zonejs : routing stops working after uncaught error

    ios - Firebase 动态链接在 iOS 上不起作用

    ios - 在 dynamicLinks.handleUniversalLink(url) 的回调中接收 nil

    `ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points` 上的 Angular 错误

    Angular 9 : NullInjectorError: No provider for CompilerFactory