我在一个Angular 4项目中工作(使用angular-cli)我将这个组件用于自动完成html输入,它可以工作,但后来我想"嘿,也许我可以创建一个节点项目并发布到npm所以我可以在任何地方使用它#34;。
这引发了一个错误,说明与我的组件不在编译路径中的相关内容,我应该将它添加到tsconfig.json,这对我来说很有意义,节点模块似乎不包含任何内容。 ts文件,只是.js
我的问题是:是否可以在npm注册表中使用角度组件? (无需在tsconfig.ts上手动添加)。
这是一个带有"默认"的回购angular cli project加上这个组件: https://bitbucket.org/tavuntu/test-ng4-suggest
(请注意我是如何尝试通过添加package.json,index.js等将其转换为节点模块的。)
这是我正在谈论的错误:
import { Ng4SuggestComponent } from '.ERROR in ./node_modules/ng4-suggest/ng4-suggest.component.ts
Module build failed: Error: /home/g/Escritorio/test-repo-downloaded/node_modules/ng4-suggest/ng4-suggest.component.ts is not part of the compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property.
at AngularCompilerPlugin.getCompiledFile (/home/g/Escritorio/test-repo-downloaded/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:643:23)
at plugin.done.then (/home/g/Escritorio/test-repo-downloaded/node_modules/@ngtools/webpack/src/loader.js:467:39)
at <anonymous>
@ ./node_modules/ng4-suggest/index.js 1:0-65
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi webpack-dev-server/client?http://0.0.0.0:0 ./src/main.ts
/ng4-suggest.component.ts';
exports.Ng4SuggestComponent = Ng4SuggestComponent;