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 build error on fresh Angular CLI project

See original GitHub issue

When adding Storybook to an Angular project that was created with the Angular CLI (monorepo approach with a single library), running npm run storybook produces the following error:

TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined

Repro steps:

> ng new design-system --create-application=false
> cd design-system
> ng generate library pattern-lib 
> npx sb init 
> npm run storybook

Build output:

design-system@0.0.0 storybook npm run docs:json && start-storybook -p 6006

design-system@0.0.0 docs:json compodoc -p ./tsconfig.json -e json -d .

1.1.11

TypeScript version used by Compodoc : 2.9.1

TypeScript version of current project : 4.2.3

Node.js version : v12.18.3

Operating system : macOS Catalina

[09:26:42] No configuration file found, switching to CLI flags. [09:26:42] Using tsconfig file : /pocs/design-system/tsconfig.json [09:26:42] Including      : /pocs/design-system/.editorconfig [09:26:42] Including      : /pocs/design-system/.gitignore [09:26:42] Including      : /pocs/design-system/README.md [09:26:42] Including      : /pocs/design-system/angular.json [09:26:42] Including      : /pocs/design-system/package.json [09:26:42] Including      : /pocs/design-system/tsconfig.json [09:26:42] Including      : /pocs/design-system/.storybook/main.js [09:26:42] Including      : /pocs/design-system/.storybook/preview.js [09:26:42] Including      : /pocs/design-system/.storybook/tsconfig.json [09:26:42] Ignoring       : /pocs/design-system/.storybook/typings.d.ts [09:26:42] Including      : /pocs/design-system/stories/Button.stories.ts [09:26:42] Including      : /pocs/design-system/stories/Header.stories.ts [09:26:42] Including      : /pocs/design-system/stories/Page.stories.ts [09:26:42] Including      : /pocs/design-system/stories/Introduction.stories.mdx [09:26:42] Including      : /pocs/design-system/stories/button.component.ts [09:26:42] Including      : /pocs/design-system/stories/button.css [09:26:42] Including      : /pocs/design-system/stories/header.component.ts [09:26:42] Including      : /pocs/design-system/stories/header.css [09:26:42] Including      : /pocs/design-system/stories/page.component.ts [09:26:42] Including      : /pocs/design-system/stories/page.css [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/README.md [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/package.json [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/karma.conf.js [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/ng-package.json [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/tsconfig.lib.json [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/tsconfig.lib.prod.json [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/tsconfig.spec.json [09:26:42] Including      : /pocs/design-system/stories/assets/colors.svg [09:26:42] Including      : /pocs/design-system/stories/assets/code-brackets.svg [09:26:42] Including      : /pocs/design-system/stories/assets/comments.svg [09:26:42] Including      : /pocs/design-system/stories/assets/flow.svg [09:26:42] Including      : /pocs/design-system/stories/assets/direction.svg [09:26:42] Including      : /pocs/design-system/stories/assets/plugin.svg [09:26:42] Including      : /pocs/design-system/stories/assets/repo.svg [09:26:42] Including      : /pocs/design-system/stories/assets/stackalt.svg [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/src/public-api.ts [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/src/test.ts [09:26:42] Ignoring       : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.component.spec.ts [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.component.ts [09:26:42] Ignoring       : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.service.spec.ts [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.module.ts [09:26:42] Including      : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.service.ts [09:26:42] Searching package.json file [09:26:42] package.json file found [09:26:42] Processing package.json dependencies [09:26:42] Searching README.md, CHANGELOG.md, CONTRIBUTING.md, LICENSE.md, TODO.md files [09:26:42] README.md file found [09:26:42] Error during /pocs/design-system/CHANGELOG read [09:26:42] Continuing without CHANGELOG.md file [09:26:42] Error during /pocs/design-system/CONTRIBUTING read [09:26:42] Continuing without CONTRIBUTING.md file [09:26:42] Error during /pocs/design-system/LICENSE read [09:26:42] Continuing without LICENSE.md file [09:26:42] Error during /pocs/design-system/TODO read [09:26:42] Continuing without TODO.md file [09:26:42] Get dependencies data [09:26:42] parsing        : /pocs/design-system/stories/Button.stories.ts [09:26:42] parsing        : /pocs/design-system/stories/Header.stories.ts [09:26:42] parsing        : /pocs/design-system/stories/Page.stories.ts [09:26:42] parsing        : /pocs/design-system/stories/button.component.ts [09:26:42] found          : ButtonComponent [09:26:42] parsing        : /pocs/design-system/stories/header.component.ts [09:26:42] found          : HeaderComponent [09:26:42] parsing        : /pocs/design-system/stories/page.component.ts [09:26:42] found          : PageComponent [09:26:42] parsing        : /pocs/design-system/projects/pattern-lib/src/public-api.ts [09:26:42] parsing        : /pocs/design-system/projects/pattern-lib/src/test.ts [09:26:42] parsing        : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.component.ts [09:26:42] found          : PatternLibComponent [09:26:42] parsing        : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.module.ts [09:26:42] found          : PatternLibModule [09:26:42]                : - exports: [09:26:42]                : - PatternLibComponent [09:26:42]                : - declarations: [09:26:42]                : - PatternLibComponent [09:26:42] parsing        : /pocs/design-system/projects/pattern-lib/src/lib/pattern-lib.service.ts [09:26:42] found          : PatternLibService [09:26:42] ------------------- [09:26:42] Project statistics  [09:26:42] - files      : 39 [09:26:42] - module     : 1 [09:26:42] - component  : 4 [09:26:42] - injectable : 1 [09:26:42] ------------------- [09:26:42] Prepare components [09:26:42]  ButtonComponent has styleUrls, include them [09:26:42]  HeaderComponent has styleUrls, include them [09:26:42]  PageComponent has styleUrls, include them [09:26:42] Prepare modules [09:26:42] Prepare injectables [09:26:42] Prepare miscellaneous [09:26:42] Process documentation coverage report [09:26:42] Generating documentation in export format json [09:26:42] Documentation generated in ./ in 0.214 seconds info @storybook/angular v6.2.9 info  info => Loading presets info => Loading 1 config file in “/pocs/design-system/.storybook” info => Loading 7 other files in “/pocs/design-system/.storybook” info => Adding stories defined in “/pocs/design-system/.storybook/main.js” info => Using prebuilt manager info => Found custom tsconfig.json info => Using implicit CSS loaders info => Using angular project ‘pattern-lib’ for configuring Storybook. ERR! TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined ERR!     at validateString (internal/validators.js:120:11) ERR!     at Object.resolve (path.js:980:7) ERR!     at Object.getAngularCliWebpackConfigOptions (/pocs/design-system/node_modules/@storybook/angular/dist/ts3.9/server/angular-cli_config.js:120:39) ERR!     at Object.webpackFinal (/pocs/design-system/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-cli.js:8:56) ERR!     at /pocs/design-system/node_modules/@storybook/core-common/dist/cjs/presets.js:274:28 ERR!  TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined ERR!     at validateString (internal/validators.js:120:11) ERR!     at Object.resolve (path.js:980:7) ERR!     at Object.getAngularCliWebpackConfigOptions (/pocs/design-system/node_modules/@storybook/angular/dist/ts3.9/server/angular-cli_config.js:120:39) ERR!     at Object.webpackFinal (/pocs/design-system/node_modules/@storybook/angular/dist/ts3.9/server/framework-preset-angular-cli.js:8:56) ERR!     at /pocs/design-system/node_modules/@storybook/core-common/dist/cjs/presets.js:274:28 { ERR!   code: ‘ERR_INVALID_ARG_TYPE’ ERR! }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

15reactions
mfrancekoviccommented, Jun 15, 2021

@fikkatra @shilman I’ve managed to make it work by just adding tsConfig to the angular.json like this 👇

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "project": "projects/my-lib/ng-package.json",
            "tsConfig": "projects/my-lib/tsconfig.lib.json" <= this line made it work.
          },
          "configurations": {
            "production": {
              "tsConfig": "projects/my-lib/tsconfig.lib.prod.json"
            },
            "development": {
              "tsConfig": "projects/my-lib/tsconfig.lib.json"
            }
          },
          "defaultConfiguration": "production"
        },

It seems like the storybook builder doesn’t know to take into account the defaultConfiguration from the angular.json.

3reactions
literalpiecommented, Jun 20, 2021

I think this issue should be reopened. Storybook should handle the case where tsConfig isn’t included in the options - especially since is the default when you create a new angular project

Read more comments on GitHub >

github_iconTop Results From Across the Web

storybook build error on fresh Angular CLI project #15246
And in our case. Storybook has all the elements (project + architect.build ) and will try to use the config of the builder...
Read more >
ERR! => Could not get angular cli webpack config
I had my component library under the projects/ directory. To use the assets of the component library in the storybook, I tried to...
Read more >
CLI options - Storybook
Storybook comes with two CLI utilities: start-storybook and build-storybook . Storybook collects completely anonymous data to help us improve user experience.
Read more >
Storybook for Angular
Create Angular project; Add @storybook/angular and babel-core; Create the config file ... npm i -g @angular/cli ng new your-angular-prj cd your-angular-prj ...
Read more >
angular/angular-cli - Gitter
23 error Failed at the grosspad-web@0.0.0 start script 'ng serve'. 23 error Make sure you have the latest version of node.js and npm...
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