自从我开始编写两个npm软件包以来,我收到了这个错误,但我找不到解决此问题的方法 . 每次运行服务时,我都有这个错误,然后如果我只是添加一个空格字符并按Ctrl S一个文件(运行Angular-CLI编译)它就会消失!怎么解决这个?
错误:
ERROR in Error遇到静态解析符号值 . 调用函数'makeDecorator',不支持函数调用 . 考虑使用对导出函数的引用替换函数或lambda,在D中解析符号NgModule:/ GitHub / angular-npm / ngx-heyl-modal / demo / node_modules / ngx-heyl-snackbar / node_modules / @ angular / core / src / metadata / ng_module.d.ts,在D中解析符号NgModule:/ GitHub / angular-npm / ngx-heyl-modal / demo / node_modules / ngx-heyl-snackbar / node_modules / @ angular / core / src / metadata . d.ts,在D中解析符号NgModule:/GitHub/angular-npm/ngx-heyl-modal/demo/node_modules/ngx-heyl-snackbar/node_modules/@angular/core/src/core.d.ts,解析符号Dg中的NgModule:/GitHub/angular-npm/ngx-heyl-modal/demo/node_modules/ngx-heyl-snackbar/node_modules/@angular/core/index.d.ts,在D:/ GitHub / angular中解析符号SnackbarModule -npm / ngx-heyl-modal / demo / node_modules / ngx-heyl-snackbar / index.ts,在D中解析符号SnackbarModule:/ GitHub / angular-npm / ngx-heyl-modal / demo / node_modules / ngx-heyl-小吃吧/ index.ts
我的包:(我在Git上的所有资源)
https://www.npmjs.com/package/ngx-heyl-modal
https://www.npmjs.com/package/ngx-heyl-snackbar
EDIT :
我尝试使用npm链接和一个简单的项目:空服务,空组件(只是html文件中的div,没有输入任何功能),这个问题仍然存在 . 我认为这是因为NgModule,也许我写的方式错了?还是我的package.json?
1 回答
您不应在包中发送
node_modules
文件夹 .您必须记住,您正在为Angular项目编写库 . 由于项目本身必须将Angular核心作为依赖项,因此库不应在其生成的包中包含Angular源 . 为此,您需要在package.json文件中设置对等依赖项 .
创建AOT兼容角度库的简单方法就是运行
ngc
但我建议你按照Angular 4 package format这是我的测试库https://www.npmjs.com/package/@zuz/lib(source,package.json中的peerDependencies)
请参阅这些链接以获取可能的解决方
https://medium.com/@trekhleb/how-to-create-aot-jit-compatible-angular-4-library-with-external-scss-html-templates-9da6e68dac6e
https://medium.com/spektrakel-blog/angular-libraries-are-fun-fece73cceb05
https://medium.com/@tinesoft/easily-create-and-publish-your-next-angular-library-with-yeoman-via-generator-ngx-library-88feb0aa63fc