Reputation: 1963
I don't know how to generate component to library in nx workspace. Here is my library structure. Libraries are in folders (for example libs/features, libs/shared). I would like to create component in library orders (libs/features/orders).
nx g @nrwl/angular:component orders-list --project orders
Error:
Could not find an NgModule. Use the skip-import option to skip importing in NgModule.
angular.json
{ "version": 2, "projects": { "orders": "libs/features/orders" } }
How to generate component to library, if module is in subfolder?
Upvotes: 0
Views: 2685
Reputation: 8042
Use features-orders
for the project.
nx g @nrwl/angular:library orders --directory=features
nx g @nrwl/angular:component orders-list --project=features-orders
Output
> NX Generating @nrwl/angular:library
CREATE libs/features/orders/README.md
CREATE libs/features/orders/tsconfig.lib.json
CREATE libs/features/orders/tsconfig.spec.json
CREATE libs/features/orders/src/index.ts
CREATE libs/features/orders/src/lib/features-orders.module.ts
CREATE libs/features/orders/project.json
CREATE libs/features/orders/tsconfig.json
UPDATE tsconfig.base.json
CREATE libs/features/orders/jest.config.ts
CREATE libs/features/orders/src/test-setup.ts
CREATE libs/features/orders/.eslintrc.json
> NX Generating @nrwl/angular:component
CREATE libs/features/orders/src/lib/orders-list/orders-list.component.html
CREATE libs/features/orders/src/lib/orders-list/orders-list.component.spec.ts
CREATE libs/features/orders/src/lib/orders-list/orders-list.component.ts
CREATE libs/features/orders/src/lib/orders-list/orders-list.component.scss
UPDATE libs/features/orders/src/lib/features-orders.module.ts
Upvotes: 2