Nx & Storybook:无法读取未定义的 属性 'registerOptionsTransform'

Nx & Storybook: Cannot read property 'registerOptionsTransform' of undefined

I am trying to install storybook on my workspace installing @nrwl/storybook and follow this guideline 但似乎存在内部错误:

Cannot read property 'registerOptionsTransform' of undefined

命令后

nx g @nrwl/angular:storybook-configuration project-name


nx report

>  NX  Report complete - copy this into the issue template

  Node : 14.16.0
  OS   : darwin x64
  npm  : 6.14.11

  nx : Not Found
  @nrwl/angular : 12.0.8
  @nrwl/cli : 12.0.8
  @nrwl/cypress : 12.0.8
  @nrwl/devkit : 12.0.8
  @nrwl/eslint-plugin-nx : 12.0.8
  @nrwl/express : Not Found
  @nrwl/jest : 12.0.8
  @nrwl/linter : 12.0.8
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 12.0.8
  @nrwl/web : Not Found
  @nrwl/workspace : 12.0.8
  @nrwl/storybook : 12.1.1
  @nrwl/gatsby : Not Found
  typescript : 4.0.7

提前致谢 安德里亚

完成升级到最新的@angular/cli 的所有基本步骤后,确保我们有@Nrwl/nx 和@Nrwl/angular,我们将package.json 文件更新为确保所有@Nrwl/xxxx 库的版本相同,在此示例中为 11.1.5:

"@nrwl/angular": "11.1.5",
"@nrwl/cli": "11.1.5",
"@nrwl/cypress": "11.1.5",
"@nrwl/eslint-plugin-nx": "11.1.5",
"@nrwl/jest": "11.1.5",
"@nrwl/tao": "11.1.5",
"@nrwl/workspace": "11.1.5",

之后我们清理并重新安装使用:

rm -rf node_modules dist
npm install

然后我们能够 运行 之前导致问题的命令。

这是我们从 运行 修改 nx report 命令后得到的结果:

  Node : 10.24.1
  OS   : darwin x64
  npm  : 6.14.12
  
  nx : 12.0.8
  @nrwl/angular : 11.1.5
  @nrwl/cli : 11.1.5
  @nrwl/cypress : 11.1.5
  @nrwl/devkit : 11.1.5
  @nrwl/eslint-plugin-nx : 11.1.5
  @nrwl/express : Not Found
  @nrwl/jest : 11.1.5
  @nrwl/linter : 11.1.5
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 11.1.5
  @nrwl/web : Not Found
  @nrwl/workspace : 11.1.5
  typescript : 4.0.7

我发现了这个问题,在迁移过程中 Nx 没有更新@angular-devkit/schematics,并且在某些时候旧版本破坏了工作区。 所以安装就足够了:

npm i -D @angular-devkit/schematics@latest