我目前正在为Angular构建一个TypeScript library(使用Angular 4).启用AOT后,我收到此错误.
ERROR in Error encountered resolving symbol values statically. Calling
function ‘ɵmakeDecorator’,function calls are not supported. Consider
replacing the function or lambda with a reference to an exported
function,resolving symbol NgModule in
/home/…/node_modules/@angular/core/core.d.ts,resolving symbol
MyModule in /home/…/dist/contents.module.d.ts,resolving symbol
MyModule in /home/…/dist/contents.module.d.ts
根据Angular版本,我得到了另一个错误:
ERROR in Error encountered resolving symbol values statically. Calling
function ‘makeDecorator’,function calls are not supported[…]
关于Angular项目的Enabling AOT阻止了这个:
ERROR in MyModule is not an NgModule
解决方法
强制你的Angular项目(或angular-cli)从你的主项目加载你的@angular依赖项,而不是库的项目.
tsconfig.json(记住angular-cli主tsconfig文件保留在src / tsconfig.app.json和tsconfig.spec.json中)
"compilerOptions": { ... "paths": { "@angular/*": ["../node_modules/@angular/*"] } }
积分到SebastianSchenk和drew-moore.
以前的尝试:
经过几个小时的测试和挖掘GitHub问题回复……
我发现它就像在客户端安装中没有node_modules /文件夹一样简单. That是我正在处理的库(单击here直到提交它正常工作).
因此,在开发设置中工作时可能有node_modules,但只要将项目集成到另一个项目中,就删除该文件夹.
在我的情况下,我在客户端文件夹中有一个node_modules文件夹的原因是由于之前的npm链接 – > npm链接my-package.由于我在开发设置中使用node_modules,因此它们也在链接文件夹中.
请注意,您的问题可能也来自其他地方:
例如:小心lambdas,改用函数.
还有更多:
> const lambda =>出口功能
> default export =>命名出口
*对于从模板访问的任何成员,应将私有受保护访问者更改为公共访问者
>动态组件模板=>静态模板
> moduleId应该在使用templateUrl的组件上设置
一定要查看full description of each of these – 学分到Isaac Mann.