Nrwl Nx 生成服务而不是lib?

Nrwl Nx generates service instead of lib?

在我的 Nx 工作区的根目录中,当我 运行 命令 ng g lib my-lib 时,它会在 服务 中生成一个名为 MyLibService =13=] 文件夹,位于我的工作区 根目录 。我希望它在 libs 文件夹 (libs/my-lib/src) 中创建一个新的 lib。 (在我升级到 v6 之前它曾经这样做过。)

此外,在创建服务后,没有任何内容 添加到我的 angular.json 文件中。

所以至少有三件事出错了:

  1. 工件生成路径错误。
  2. 它正在生成 service 而不是 lib
  3. angular.json
  4. 中未记录任何内容

我做错了什么?

谢谢。

更新 #1

我创建了一个新的测试工作区,添加了一个应用程序,并使用与上面相同的命令向其中添加了一个库。一切都按预期工作,所以我认为这意味着我的环境(包等)是正确的。我比较了虚拟工作空间和我的真实工作空间的 angular.json 文件,发现我的真实工作空间缺少一个看起来相关的条目:"defaultCollection": "@nrwl/schematics"

我添加了那个条目,现在当我尝试创建一个库时,它在那里停留 10-15 秒然后报告:

ERROR! test2/karma.conf.js does not exist..
ERROR! test2/ng-package.json does not exist..
ERROR! test2/ng-package.prod.json does not exist..
ERROR! test2/package.json does not exist..
ERROR! test2/tsconfig.lib.json does not exist..
ERROR! test2/tsconfig.spec.json does not exist..
ERROR! test2/tslint.json does not exist..
ERROR! test2/src/test.ts does not exist..
ERROR! test2/src/index.ts does not exist..
ERROR! test2/src/lib/test2.component.ts does not exist..
ERROR! test2/src/lib/test2.module.ts does not exist..
ERROR! libs/test2/src/lib/test2.module.ts does not exist..
ERROR! libs/test2/src/index.ts does not exist..
ERROR! libs/test2/tsconfig.lib.json does not exist..
ERROR! libs/test2/tsconfig.spec.json does not exist..
ERROR! libs/test2/tslint.json does not exist..
ERROR! libs/test2/karma.conf.js does not exist..
The Schematic workflow failed. See above.

'test2' 是我尝试创建的库的名称

现在,任何地方都没有创建任何东西,我的angular.json也没有被修改。

我将继续深入研究。

已解决。我将真实工作区 package.json 中的所有软件包版本重置为 package.json 中有效的版本(通常为 Angular 6.0.1)。清除了我的 node_modules 文件夹和 运行 纱线。现在一切正常。

关于 Nrwl/Nx GitHub 存储库中的一个无关问题,Victor Savkin 评论说 Angular 6.1 将在 Nx 6.2 之前得到支持。

经验教训:不要总是更新到最新版本的东西...稍等一下,保持一两个版本,除非您有特定的升级原因!