我将我的 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
.通过重命名(临时)命令可以工作。
最佳答案
根据您的评论,我认为以下命令适合您。您的 directory
有 /libs/booking
,应该是 libs/booking
ng generate @nrwl/workspace:library --name=service --style=scss --directory=libs/booking
关于angular - 使用 NX 命令创建 Angular 库时出现 SchematicsException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66765843/