【问题标题】:SchematicsException when creating an angular library with NX Commands使用 NX 命令创建角度库时出现 SchematicsException
【发布时间】:2021-06-20 06:23:27
【问题描述】:

我将我的 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。通过重命名它(暂时)该命令起作用。

【问题讨论】:

  • 你可以试试ng generate @nrwl/workspace:library --name=service --style=scss --directory=libs/booking
  • 前导斜杠和 tsconfig 文件名的组合。如果你写一个答案,我会接受它。

标签: angular angular-cli nrwl-nx


【解决方案1】:

根据您的评论,我认为以下命令适合您。您的 directory/libs/booking,应该是 libs/booking

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-08-03
    • 2019-05-23
    • 1970-01-01
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    • 2018-02-14
    • 2011-10-26
    相关资源
    最近更新 更多