Search code examples
javascriptangulartypescriptstorybookangular-storybook

Running Storybook on an Angular Library Project


I created a new Angular Workspace.

ng new workspace --create-application=false
cd workspace

And then generated a library within the workspace.

ng g library lib

I also generated a playground for testing the library.

ng g application playground

Then I initialized storybook and tried to run it.

npx storybook@latest init
npm run storybook

When attempting to run storybook it logs this error:

info => Using angular project "lib:build" for configuring Storybook
ERR! Error: error TS6053: File '../false' not found.
ERR!
ERR!     at readTsconfig (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/read-tsconfig.js:51:15)
ERR!     at async configureI18nBuild (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/i18n-options.js:125:22)
ERR!     at async generateI18nBrowserWebpackConfigFromContext (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:67:36)
ERR!  Error: error TS6053: File '../false' not found.
ERR!
ERR!     at readTsconfig (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/read-tsconfig.js:51:15)
ERR!     at async configureI18nBuild (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/i18n-options.js:125:22)
ERR!     at async generateI18nBrowserWebpackConfigFromContext (/Users/oleersoy/Temp/workspace/node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:67:36)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

info => Loading presets
✔ Would you like to send crash reports to Storybook? … yes

How can I fix this?


Solution

  • In the workspace where your library is located, you should have a .storybook directory. Well, in that directory you will have a tsconfig.json file. Edit line 1, which you currently have as:

        "extends": "../false"
    

    to

        "extends": "../tsconfig.json".
    

    And don't forget to also add the "include" path

    "../stories/**/*"