(Angular 2+) Loading modules from outside the main.ts directory throws "Please add @NgModule annotation" error

94 Views Asked by At

I'm having an issue with loading a module that lives outside the node_modules directory.

This directory structure works:

+ node_modules
+ Resources
+--- app
+------- main.ts
+------- components
+------- modules
+----------- b.module.ts
+----------- a.module.ts

This also works:

+ node_modules
+ b.module.ts
+ Resources
+--- app
+------- main.ts
+------- components
+------- modules
+----------- a.module.ts

But this throws a "Please add @NgModule annotation" error, even though b.module.ts does have an @NgModule annotation and works in the two directory structures above. Should this work at all?

+ BModule
+---- b.module.ts
+ myApp
+---- node_modules
+---- Resources
+------- app
+----------- main.ts
+----------- components
+----------- modules
+--------------- b.module.ts
+--------------- a.module.ts

I'm wondering if I need to make it a separate library like this: https://hackernoon.com/how-to-create-library-in-angular-2-and-publish-to-npm-from-scratch-f2b1272d6266

EDIT: After more debugging I found that the app is using browserify in gulp, and is not including the contents of b.module.ts in the output js bundle file.

0

There are 0 best solutions below