builder-vite
builder-vite copied to clipboard
[Bug] Cannot read property 'createExpressionStatement' of undefined
What version of vite are you using?
3.1.1
System info and storybook versions
System: OS: Linux Mint 20.3 una npmPackages: "@storybook/addon-actions": "^6.5.12", "@storybook/addon-essentials": "^6.5.12", "@storybook/addon-interactions": "^6.5.12", "@storybook/addon-links": "^6.5.12", "@storybook/builder-vite": "^0.2.2", "@storybook/react": "^6.5.12" Binaries: Node: v14.18.1 Yarn: 1.22.17 npm: 8.16.0 Browser: Google Chrome
Describe the Bug
When I run yarn storybook, I get the following error:
Cannot read property 'createExpressionStatement' of undefined
Cannot read property 'createExpressionStatement' of undefined (x2)
10:30:38 AM [vite] Internal server error: Cannot read property 'createExpressionStatement' of undefined
Plugin: vite:react-docgen-typescript
File: /home/davi/work/harmonize-portal/apps/dashboard/src/Common/components/SupaTable/SupaTable.tsx
at setDisplayName (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:53:62)
at /home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:101:30
at Array.map (<anonymous>)
at generateDocgenCodeBlock (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:100:44)
at TransformContext.transform (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:182:14)
at Object.transform (file:///home/davi/work/harmonize-portal/node_modules/vite/dist/node/chunks/dep-a713b95d.js:41088:44)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async loadAndTransform (file:///home/davi/work/harmonize-portal/node_modules/vite/dist/node/chunks/dep-a713b95d.js:37349:29)
10:30:38 AM [vite] Internal server error: Cannot read property 'createExpressionStatement' of undefined
Plugin: vite:react-docgen-typescript
File: /home/davi/work/harmonize-portal/apps/dashboard/src/Questionnaire/components/QuestionnaireAlertChart/makePROTableDefinitions.tsx
at setDisplayName (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:53:62)
at /home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:101:30
at Array.map (<anonymous>)
at generateDocgenCodeBlock (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:100:44)
at TransformContext.transform (/home/davi/work/harmonize-portal/node_modules/@joshwooding/vite-plugin-react-docgen-typescript/dist/index.cjs:182:14)
at Object.transform (file:///home/davi/work/harmonize-portal/node_modules/vite/dist/node/chunks/dep-a713b95d.js:41088:44)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async loadAndTransform (file:///home/davi/work/harmonize-portal/node_modules/vite/dist/node/chunks/dep-a713b95d.js:37349:29)
```
### Link to Minimal Reproducible Example
_No response_
### Participation
- [ ] I am willing to submit a pull request for this issue.
@davisuga-h thanks for the report. Are you able to narrow down which component this is happening in, and share that component here? It seems that react-docgen-typescript isn't able to find a display name for the component.
@davisuga-h Could you try upgrading your typescript version to the latest and run storybook. I was facing the same issue and this resolved it for me.
TS version that I'm using is 4.8.4 I also changed the extension of main.js and preview.js in the .storybook directory to ".ts"
Hope this helps. Cheers!
@davisuga-h Could you try upgrading your typescript version to the latest and run storybook. I was facing the same issue and this resolved it for me.
TS version that I'm using is 4.8.4 I also changed the extension of main.js and preview.js in the .storybook directory to ".ts"
Hope this helps. Cheers!
Thanks, it works for me also.
I am working with Monorepo, so i changed the storybook from main package to each project, and forget to add the typescript on package.json