storybook: Cannot find type definition file for 'webpack-env'

Describe the bug Just importing addParameters into my story causes the build to break. It does not launch when you run yarn storybook or npm run storybook

** Error **

ERROR in .../node_modules/@storybook/angular/dist/client/preview/index.d.ts
ERROR in .../node_modules/@storybook/angular/dist/client/preview/index.d.ts(2,23):
TS2688: Cannot find type definition file for 'webpack-env'.

To Reproduce Steps to reproduce the behavior:

  1. Import addParameters into your story

Expected behavior Works…

Code snippets

import { addParameters} from '@storybook/angular';

System:

 npx -p @storybook/cli@next sb init --type angular

Additional context I had to install the @next cli, because of a different bug in Angular and Storybook.

Dev Dependencies

    "@storybook/addon-actions": "^5.2.0-beta.39",
    "@storybook/addon-backgrounds": "^5.1.11",
    "@storybook/addon-links": "^5.2.0-beta.39",
    "@storybook/addon-notes": "^5.2.0-beta.39",
    "@storybook/addons": "^5.2.0-beta.39",
    "@storybook/angular": "^5.2.0-beta.39",

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 44 (34 by maintainers)

Most upvoted comments

Can confirm this.

@VladislavLobakh If you can, use skipLibCheck: true as a workaround until this is solved Please let me know if this workaround doesn’t work for you!

Edit Another workaround is installing the types for webpack-env => npm i -D @types/webpack-env

I try to figure out what’s wrong later this week

Example .storybook/tsconfig.json

{
  "extends": "../tsconfig.app.json",
  "compilerOptions": {
    "types": [
      "node"
    ],
    "skipLibCheck": true
  },
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../projects/**/*"
  ],
  "files": [
    "./typings.d.ts"
  ]
}

To fix install types for webpack by;

npm install --save-dev webpack-env

After looking at the node_modules/@storybook/angular/dist/client/preview/index.d.ts I commented out the reference and it did not break my build, I then googled reference types and webpack-env.

These types did not get included by the ng cli tool when creating a project.

I saw that a lot of packages added webpack env to the types property of tsconfig.json

I was able get rid of it in angular but I’m not sure why it was added in the first place.

If this is a trouble maker we can try to get rid of this again. Or add an explicit dependency on webpack-env in storybook/core

¡Ay Caramba!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.8 containing PR #9536 that references this issue. Upgrade today to try it out!

Closing this issue. Please re-open if you think there’s still more to do.

@gaetanmaisse Yes, in the day hopefully.

Reopening this issue, it should/will 🤞 be fixed by #9536.

Can confirm that it’s dependency in @storybook/react, @storybook/html, and a bunch of others … but NOT in @storybook/angular.

@ndelangen @kroeder @gaetanmaisse can we add this?

@astorije sorry typescript newb here. hoping @ndelangen @kroeder @gaetanmaisse can help you out

@robaxelsen it’s been patched, available in the latest 5.2.x!

Great, thank you so much

I can confirm that this fixed the issue also for a stencil project with storybook.

@kroeder @ndelangen Thoughts on typedefs for npmlog for @astorije ?

@robaxelsen it’s been patched, available in the latest 5.2.x!

@robaxelsen Oops, I missed that! SMH. Ok I’ll patch that in and comment here when it’s ready. Thanks for your patience.

I’ll release a patch PR later today that will hopefully fix some if not all of these issues.