角9:NgModule.imports中X位置的值不是引用 [英] Angular 9: Value at position X in the NgModule.imports is not a reference

查看:671
本文介绍了角9:NgModule.imports中X位置的值不是引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Angular App从v8升级到了v9。该项目使用Angular 8和moment.js导入了一个自定义UI库。

I upgraded an Angular App from v8 to v9. The project imports a custom UI library using Angular 8 and moment.js.

构建时:

When I build it:


  1. 它会生成警告:

  1. It generates a warning:



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语言环境:

In the @myLib/catalogue.js file of the library (inside node_modules folder), the moment.js DE locale is imported as following:

import 'moment/locale/de';



  1. 还会触发编译错误:

  1. Compilation errors are also triggered:



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)超出了导入数组的范围。

The text of the warning seems explaining exactly the compilation error, where the position (2 in this case) is out of range of the imports array.

我看到了不同的关节es / 有关深度链接的github问题,但没有有效的解决方案。

I have seen different articles/github issues about deep-links, but no working solution.

推荐答案

就我而言,问题与导入的库有关,该库与Angular v9不兼容(除其他外,它不兼容)

In my case the issue was related to an imported library, that was not Angular v9 compatible (among other things it was not using deep links to Angular Material and moment.js).

我很幸运,因为该库是一个实习生,我可以修复这些问题并重新发布。之后,它的构建没有任何问题或我的项目发生任何变化。

I was lucky as the library is an intern one and I could fix these points and republish it. After that it built without any problems or changes in my project.

这篇关于角9:NgModule.imports中X位置的值不是引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆