Skip to content

TypeError: Cannot read properties of undefined (reading 'imports') #6832

@unional

Description

@unional

Describe the bug

When running vitest on https://github.com/repobuddy/storybook-addon-vis/tree/und-imports,
I notice it emits two warnings:

``sh
10:39:13 AM [vite] ✨ new dependencies optimized: @vitest/coverage-v8/browser
10:39:13 AM [vite] ✨ optimized dependencies changed. reloading

[vitest] Vite unexpectedly reloaded a test. This may cause tests to fail, lead to flaky behaviour or duplicated test runs.
For a stable experience, please add mentioned dependencies to your config's optimizeDeps.include field manually.

...

10:39:15 AM [vite] ✨ new dependencies optimized: @storybook/experimental-addon-test/internal/test-utils
10:39:15 AM [vite] ✨ optimized dependencies changed. reloading
[vitest] Vite unexpectedly reloaded a test. This may cause tests to fail, lead to flaky behaviour or duplicated test runs.
For a stable experience, please add mentioned dependencies to your config's optimizeDeps.include field manually.


So I follow exactly what it suggest:

optimizeDeps: {
	include: ['@storybook/experimental-addon-test/internal/test-utils', '@vitest/coverage-v8'],
},

I starts getting this error both locally (WSL and mac):

```sh
TypeError: Cannot read properties of undefined (reading 'imports')
 ❯ node_modules/.pnpm/[email protected]_@[email protected]/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:50832:71
 ❯ process.processTicksAndRejections node:internal/process/task_queues:105:5

Reproduction

https://github.com/repobuddy/storybook-addon-vis/tree/und-imports

pnpm i
pnpm verify

System Info

System:
    OS: macOS 14.7
    CPU: (10) arm64 Apple M1 Pro
    Memory: 95.86 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - ~/.local/state/fnm_multishells/62333_1730395978755/bin/node
    npm: 10.8.3 - ~/.local/state/fnm_multishells/62333_1730395978755/bin/npm
    pnpm: 9.12.3 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
    bun: 0.1.6 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 129.1.70.119
    Chrome: 130.0.6723.91
    Safari: 18.0
  npmPackages:
    @vitest/coverage-v8: 2.1.4 => 2.1.4 
    vitest: ^2.1.3 => 2.1.4

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions