Skip to content

SSR Error: "Cannot read properties of undefined (reading 'wrapDynamicImport')" with Vite 7 #14149

@Dodo-Dude

Description

@Dodo-Dude

Describe the bug

When running svelte-check or vitest in a SvelteKit project using Vite 7, a persistent SSR error occurs deep inside the SvelteKit runtime. This appears to happen during SSR module evaluation. Simultaneously, a Tailwind CSS error Cannot apply unknown utility class is thrown, likely as a symptom of the unstable build state caused by the SSR error.

The issue persists despite ensuring compatible dependencies, performing a full clean reinstall (rm -rf node_modules, rm package-lock.json, npm cache clean), and correcting the Vite plugin order.

Reproduction

Reproduction

The error occurs consistently when running type checking or unit tests in a standard SvelteKit project with the dependencies listed below.

Steps to reproduce:

  1. Set up a SvelteKit project with vite, vitest, and @tailwindcss/vite.
  2. Run npm run check or npm run test:unit.
  3. The errors are logged to the console, although the process can finish successfully if the errors are treated as warnings.

Logs

Logs

Vite SSR Error:
`[vite] (ssr) Error when evaluating SSR module /@fs/.../node_modules/@sveltejs/kit/src/runtime/server/index.js: Cannot read properties of undefined (reading 'wrapDynamicImport')`

Tailwind CSS Error:
`Error: Cannot apply unknown utility class 'text-gray-500'.`

System Info

- OS: Windows
- SvelteKit: v2.22.0
- Vite: v7.0.4
- Tailwind CSS / @tailwindcss/vite: v4.1.11
- Node: v22.17.1

Severity

blocking all usage of SvelteKit

Additional Information

This appears to be a bug within the SvelteKit or Vite SSR runner, as standard troubleshooting steps (clean install, config correction) do not resolve the issue. The project's build process has been stabilized by treating these errors as non-failing warnings, but the underlying issue remains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions