Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@nrwl/storybook not able to build or serve an angular storybook #8373

Closed
SeverinFriede opened this issue Jan 4, 2022 · 4 comments
Closed
Assignees
Labels
outdated scope: storybook Issues related to Storybook support in Nx type: bug

Comments

@SeverinFriede
Copy link

SeverinFriede commented Jan 4, 2022

Current Behavior

I've migrated my workspace (containing angular apps, react and angular libs and a HTML/CSS library) by using nx migrate latest to the latest version of nx, angular etc.
All other tasks like linting, testing or building work fine but running nx run angular:build-storybook or nx run angular:storybook (where angular is really the name of our library project) do fail with the following output:

> nx run angular:build-storybook --verbose 

>  NX  ui framework: @storybook/angular

Cannot read property 'targets' of undefined
TypeError: Cannot read property 'targets' of undefined
    at readTargetOptions (\code\web-essentials\node_modules\@nrwl\devkit\src\executors\read-target-options.js:13:54)
    at resolveCommonStorybookOptionMapper (\code\web-essentials\node_modules\@nrwl\storybook\src\executors\utils.js:142:60)
    at storybookOptionMapper (\code\web-essentials\node_modules\@nrwl\storybook\src\executors\build-storybook\build-storybook.impl.js:28:140)
    at \code\web-essentials\node_modules\@nrwl\storybook\src\executors\build-storybook\build-storybook.impl.js:13:24
    at Generator.next (<anonymous>)
    at fulfilled (\code\web-essentials\node_modules\tslib\tslib.js:114:62)

———————————————————————————————————————————————

>  NX   ERROR  Running target "angular:build-storybook" failed

  Failed tasks:

  - angular:build-storybook

  Hint: run the command with --verbose for more details.

Expected Behavior

Building or serving the storybook properly.

Steps to Reproduce

Using nx run angular:storybook or nx run angular:build-storybook
I've also deleted package-lock.json and cleaned node_modules (twice) so far.

Failure Logs

TypeError: Cannot read property 'targets' of undefined
    at readTargetOptions (\code\web-essentials\node_modules\@nrwl\devkit\src\executors\read-target-options.js:13:54)
    at resolveCommonStorybookOptionMapper (\code\web-essentials\node_modules\@nrwl\storybook\src\executors\utils.js:142:60)
    at storybookOptionMapper (\code\web-essentials\node_modules\@nrwl\storybook\src\executors\build-storybook\build-storybook.impl.js:28:140)
    at \code\web-essentials\node_modules\@nrwl\storybook\src\executors\build-storybook\build-storybook.impl.js:13:24
    at Generator.next (<anonymous>)
    at fulfilled (\code\web-essentials\node_modules\tslib\tslib.js:114:62)

Environment

>  NX  Report complete - copy this into the issue template

  Node : 14.17.4
  OS   : win32 x64
  npm  : 7.21.0

  nx : 13.4.3
  @nrwl/angular : 13.4.3
  @nrwl/cli : 13.4.3
  @nrwl/cypress : 13.4.3
  @nrwl/devkit : 13.4.3
  @nrwl/eslint-plugin-nx : 13.4.3
  @nrwl/express : undefined
  @nrwl/jest : 13.4.3
  @nrwl/linter : 13.4.3
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : undefined
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.4.3
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.4.3
  @nrwl/web : 13.4.3
  @nrwl/workspace : 13.4.3
  @nrwl/storybook : 13.4.3
  @nrwl/gatsby : undefined
  typescript : 4.5.4
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
         @angular/animations: 13.1.1
         @angular/cdk: 13.1.1
         @angular/common: 13.1.1
         @angular/compiler: 13.1.1
         @angular/core: 13.1.1
         @angular/forms: 13.1.1
         @angular/platform-browser: 13.1.1
         @angular/platform-browser-dynamic: 13.1.1
         @angular/router: 13.1.1
         @angular-devkit/build-angular: 13.1.2
         @angular/cli: 13.1.2
         @angular/compiler-cli: 13.1.1
         @angular/language-service: 13.1.1
         @storybook/angular: 6.4.9
@SeverinFriede
Copy link
Author

I had a look at @nrwl\storybook\src\executors\utils.js:142:60 and there the problem was that it could not resolve the default project. So after adding "defaultProject": "angular" to my nx.json it works again.

@mandarini
Copy link
Member

Hi there @SeverinFriede ! Thanks for filing an issue. Can you check out this comment here? It is our intention for the error messaging to be better. At this point, specifying the projectBuildConfig will do the trick for you! :)

Let me know if you need anything else, and I can reopen the issue! :)

@mandarini mandarini added the scope: storybook Issues related to Storybook support in Nx label Jan 5, 2022
@mandarini mandarini self-assigned this Jan 17, 2022
@mandarini
Copy link
Member

New docs for styles and stylePreprocessorOptions

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: storybook Issues related to Storybook support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

2 participants