[英]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.我将我的 NX 工作区更新到最新版本 (
"@nrwl/angular": "11.5.2"
),并在 monorepo 中将其与 Angular 应用程序 (v 11.2.6) 一起使用。
I would like to generate a new Angular library using the following command:我想使用以下命令生成一个新的 Angular 库:
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.我还清除了 node_modules 并再次重新安装了软件包,但没有任何运气。
UPDATE更新
I leave below the steps that helped me to fix the issue after the hint from Shashank:在 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
.这是由于 tsconfig.json 对于 NX 应该仍然是
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
根据您的评论,我认为以下命令对您有用。您的
directory
有/libs/booking
,应该是libs/booking
ng generate @nrwl/workspace:library --name=service --style=scss --directory=libs/booking
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.