storybook: Angular 6 and Storybook v4.0.0-alpha.13 don't work well together

After installing Storybook v4.0.0-alpha.13, Storybook runs fine, however my Angular 6 app has stopped working. The app has been created using Angular CLI. Now if I try to start it using ng serve, it throws the following error:

$ ng serve
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2018-07-11T03:30:07.801Z
Hash: 50081d01a055f9be783d
Time: 3131ms
chunk {main} main.js, main.js.map (main) 1.95 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 693 bytes [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 325 kB [initial] [rendered]

ERROR in node_modules/@storybook/angular/index.d.ts(38,51): error TS2304: Cannot find name 'NodeModule'.
node_modules/@storybook/angular/index.d.ts(42,44): error TS2304: Cannot find name 'NodeRequire'.
node_modules/@storybook/angular/index.d.ts(42,65): error TS2304: Cannot find name 'NodeModule'.
src/stories/index.stories.ts(9,22): error TS2304: Cannot find name 'module'.
src/stories/index.stories.ts(14,21): error TS2304: Cannot find name 'module'.
src/stories/index.stories.ts(41,29): error TS2304: Cannot find name 'module'.
src/stories/index.stories.ts(49,29): error TS2304: Cannot find name 'module'.

「wdm」: Failed to compile.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 17 (8 by maintainers)

Most upvoted comments

Probably you need a similar solution as here

You might also check https://github.com/storybooks/storybook/issues/4481 if you can’t start your angular app anymore after updating to rc.3

This is fixed in the latest CLI sb init - Existing projects have to manually do this I have plans to make it easier for existing storybook projects but I’m still in the thinking phase 🙂 https://github.com/storybooks/storybook/issues/4486

@igor-dv Perfect! That was it. When building the stories Node types were needed! Thanks

I mean you need to add it to the types in the tsconfig

Something like this:

"compilerOptions": {
    "types": [
      "node"
    ]
  },