使用 NX 命令创建 angular 库时出现 SchematicsException

SchematicsException when creating an angular library with NX Commands

我将我的 NX 工作区更新到最新版本 ("@nrwl/angular": "11.5.2"),并在 monorepo 中将其与 Angular 应用程序 (v 11.2.6) 一起使用。

我想使用以下命令生成一个新的 Angular 库:

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

但是我在控制台中收到以下错误:

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.

命令以某种方式 在项目名称 前添加了一个破折号 -,生成了错误。

我也删除了 node_modules 并重新安装了软件包,但没有成功。


更新

在 Shashank 的提示下,我留下了帮助我解决问题的步骤:

如果删除目录参数中的前导 /,则会出现以下错误:

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

TypeError: Cannot read property 'paths' of undefined

由于 tsconfig.json,NX 仍应 tsconfig.base.json。通过重命名它(暂时)命令工作。

根据您的评论,我认为下面的命令适用于 you.Your directory/libs/booking,应该是 libs/booking

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