简体   繁体   中英

SchematicsException when creating an angular library with NX Commands

I updated my NX Workspace to the latest version ( "@nrwl/angular": "11.5.2" ) using it with Angular apps (v 11.2.6) in a monorepo.

I would like to generate a new Angular library using the following command:

ng generate @nrwl/angular:library --name=service --style=scss --directory=/libs/booking

But I receive the following error in the console:

SchematicsException [Error]: Project name "-libs-booking-service" is not valid.
New project names must start with a letter, and must contain only alphanumeric 
characters or dashes. When adding a dash the segment after the dash must also
start with a letter.

Somehow the command adds a dash - before the project name , generating the error.

I also wiped out the node_modules and reinstalled the packages again, but without any luck.


UPDATE

I leave below the steps that helped me to fix the issue after the hint from Shashank:

If I remove the leading / in the directory parameter, I get the following error:

ng generate @nrwl/angular:library --name=services --style=scss --directory=libs/booking

TypeError: Cannot read property 'paths' of undefined

That it is due to the tsconfig.json that for NX should still be tsconfig.base.json . By renaming it (temporarily) the command works.

As per your comment, I think below command works for you.Your directory had /libs/booking , which should have been libs/booking

ng generate @nrwl/workspace:library --name=service --style=scss --directory=libs/booking

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM