[英]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
。 通过重命名它(暂时)该命令起作用。
根据您的评论,我认为以下命令对您有用。您的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.