question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook fails to launch without a default project

See original GitHub issue

Current Behavior

If workspace.json does not set a default project, launching storybook after running nx g @nrwl/angular:storybook-configuration project-name results in the following error

> nx run <project>:storybook 
Cannot read property 'targets' of undefined

See https://github.com/nrwl/nx/blob/master/packages/storybook/src/executors/utils.ts#L188 and https://github.com/nrwl/nx/blob/master/packages/storybook/src/executors/utils.ts#L212, where defaultProjectName ends up being undefined.

Expected Behavior

Launch storybook after initial configuration without additional modifications to workspace project configuration.

Steps to Reproduce

Setting projectBuildConfig string equal to the name of the respective project in configuration (https://nx.dev/p/a/storybook/build#projectbuildconfig) seems to resolve.

Failure Logs

Environment

npx nx report            

>  NX  Report complete - copy this into the issue template

  Node : 12.22.7
  OS   : linux x64
  yarn : 1.22.17
  
  nx : 13.3.0
  @nrwl/angular : 13.3.0
  @nrwl/cli : 13.3.0
  @nrwl/cypress : 13.3.0
  @nrwl/devkit : 13.3.0
  @nrwl/eslint-plugin-nx : 13.3.0
  @nrwl/express : undefined
  @nrwl/jest : 13.3.0
  @nrwl/linter : 13.3.0
  @nrwl/nest : 13.3.0
  @nrwl/next : undefined
  @nrwl/node : 13.3.0
  @nrwl/nx-cloud : undefined
  @nrwl/react : undefined
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.3.0
  @nrwl/web : undefined
  @nrwl/workspace : 13.3.0
  @nrwl/storybook : 13.3.6
  @nrwl/gatsby : undefined
  typescript : 4.5.3
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
  	 @angular/animations: 13.1.0
  	 @angular/cdk: 13.1.0
  	 @angular/common: 13.1.0
  	 @angular/compiler: 13.1.0
  	 @angular/core: 13.1.0
  	 @angular/forms: 13.1.0
  	 @angular/material: 13.1.0
  	 @angular/platform-browser: 13.1.0
  	 @angular/platform-browser-dynamic: 13.1.0
  	 @angular/platform-server: 13.1.0
  	 @angular/router: 13.1.0
  	 angular-auth-oidc-client: 11.6.8
  	 angular-datatables: 9.1.1
  	 @angular-devkit/build-angular: 13.0.4
  	 @angular/cli: 13.0.4
  	 @angular/compiler-cli: 13.1.0
  	 @angular/language-service: 13.1.0
  	 @storybook/angular: 6.4.9

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:21 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
BOBRIWEcommented, Jan 12, 2022

I meant that we’re running e2e tests and storybook like this: nx e2e storybook-app-e2e. And before e2e tests started, it tries to start storybook. It means that I need to pass --projectBuildConfig there somehow.

But I found solution, you need to pass projectBuildConfig to storybook options

"storybook": {
  "builder": "@nrwl/storybook:storybook",
  "options": {
    "uiFramework": "@storybook/angular",
    "port": 4400,
    "config": {
      "configFolder": "apps/storybook-app/.storybook"
    },
    // Here
    "projectBuildConfig": "storybook-app:build-storybook"
  },
  "configurations": {
    "ci": {
      "quiet": true
    }
  }
},
3reactions
nick-allencommented, Dec 20, 2021

Would recommend at least a doc update, since it took me spinning up a debugger and tracking down the lines mentioned in my initial message to understand why this was failing. None of the getting started docs made any mention about default project setups, and the error caused is not obvious. The better solution in my mind is to just assume the projectBuildConfig value should be automatically set to the target project used when running the command if it’s not set, using the default project, even if available, as the default doesn’t make sense to me if I’m already launching using a specific project config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Environment variables - Storybook - JS.ORG
By default, Storybook will open a new Chrome window as part of its startup process. If you don't have Chrome installed, make sure...
Read more >
@storybook/builder-vite - npm
The default project root is set to the parent directory of the storybook configuration directory. This can be overridden in viteFinal. Known ...
Read more >
Storybook in examples. Beginner's guide | LITSLINK | - Medium
NOTE: Storybook needs to be installed into a project that is already setup with a framework. It will not work on an empty...
Read more >
Error message "error:0308010C:digital envelope routines ...
Open terminal and paste these as described: ... When you attempt to use SSL in Node.js v17 or later without also upgrading those...
Read more >
Storybook in React Native - collective:mind | DEV
Our first goal is to get to the default Storybook and after that we ... Long story short this will allow us to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found