profile
viewpoint

Ask questionsCannot 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",
storybookjs/storybook

Answer questions astorije

Hey @shilman, we are in the process of upgrading from 5.1.1 to 5.2.1 and we are still seeing this issue (and then some):

ERROR in [at-loader] ./node_modules/@storybook/react/dist/client/preview/index.d.ts:2:23
    TS2688: Cannot find type definition file for 'webpack-env'.

ERROR in [at-loader] ./node_modules/@storybook/addon-knobs/dist/components/types/Color.d.ts:3:29
    TS7016: Could not find a declaration file for module 'react-color'. '/Users/jeremie/GitHub/CloudHealth/cht-ui-component-lib/node_modules/react-color/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/react-color` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-color';`

ERROR in [at-loader] ./node_modules/@storybook/node-logger/dist/index.d.ts:1:20
    TS7016: Could not find a declaration file for module 'npmlog'. '/Users/jeremie/GitHub/CloudHealth/cht-ui-component-lib/node_modules/npmlog/log.js' implicitly has an 'any' type.
  Try `npm install @types/npmlog` if it exists or add a new declaration (.d.ts) file containing `declare module 'npmlog';`

For context, here is everything related to storybook in our package.json:

    "@storybook/addon-a11y": "5.2.1",
    "@storybook/addon-actions": "5.2.1",
    "@storybook/addon-knobs": "5.2.1",
    "@storybook/addon-notes": "5.2.1",
    "@storybook/addons": "5.2.1",
    "@storybook/node-logger": "5.2.1",
    "@storybook/react": "5.2.1",
    "@storybook/theming": "5.2.1",

And we run it with:

"storybook": "start-storybook --config-dir storybook --port 9001 --static-dir .",

All the errors above disappear when re-adding "skipLibCheck": true in the tsconfig.json file (which I was hoping to remove now that https://github.com/storybookjs/storybook/issues/7069 / https://github.com/storybookjs/storybook/pull/7072 have been shipped in 5.2.x).

If that's any useful, here is our tsconfig.json:

<details>

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["dom", "es2015", "es2017", "esnext.asynciterable"],
    "jsx": "react",
    "declaration": true,
    "preserveWatchOutput": true,
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": "./",
    "paths": {
      "react": ["node_modules/@types/react"]
    },
    "outDir": "../storybook_dist",
    "skipLibCheck": true
  }
}

</details>

Any idea how to fix this?

useful!
source:https://uonfu.com/
Github User Rank List