【发布时间】:2019-01-05 16:32:20
【问题描述】:
在我的 Nx 工作区的根目录中,当我运行命令 ng g lib my-lib 时,它会在 我的工作区的根目录下的 myLib/src/libs 文件夹中生成一个名为 MyLibService 的 服务 /强>。我希望它会在 libs 文件夹 (libs/my-lib/src) 中创建一个新的 lib。 (在我升级到 v6 之前,它曾经这样做过。)
- Angular 6.1.0
- NRWL Nx 6.1.1
- Angular CLI 6.1.0-rc.0(固定到该位置以避免https://github.com/nrwl/nx/issues/640)
此外,nothing 会在服务创建后添加到我的angular.json 文件中。
所以至少有三件事出了问题:
- 生成工件的路径错误。
- 它正在生成
service而不是lib -
angular.json中没有记录任何内容
我做错了什么?
谢谢。
更新 #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 没有被修改。
我将继续深入研究。
【问题讨论】:
标签: angular-cli nrwl