Create an external module in Angular 4

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

I am creating a simple module (widget.module.ts) that has a component (widget.component.ts), so I am creating a package.json file with 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 application

ng new MySimpleApp

on the way MySimpleApp I will contact my module

npm link @mylibs/widget

but when i run my application

ng serve

I have this error:

'WidgetModule' imported by the AppModule module. Add the @NgModule annotation.

+4
source share

Source: https://habr.com/ru/post/1680640/


All Articles