Create an external module in Angular 4

Viewed 1059

I want create an external module and then import it into my project.

I create a simple module ( widget.module.ts ) that have a component ( widget.component.ts ), so i generate a package.json file using npm

npm init --scope=@mylibs
# i give the name widget
# the entrypoint is widget.module.js

npm install
# it create node_module folder

npm link
# it create the link

then i create a simple app

ng new MySimpleApp

in the MySimpleApp path i link my module

npm link @mylibs/widget

but when i launch my app

ng serve

i have this error:

'WidgetModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

0 Answers
Related