Skip to content

vite 6 breaks deno support when npm: specifer is used in config file #18822

Closed
@kazushisan

Description

Describe the bug

Vite fails to run on Deno after upgrading to v6 when the config file includes an import statement with the npm: specifier.

I think I have a solution so I'd like to work on a patch!

Reproduction

https://github.com/kazushisan/vite-v6-deno-bug

Steps to reproduce

using the following config:

import { defineConfig } from 'npm:vite@6'
import react from 'npm:@vitejs/plugin-react'

// @deno-types="npm:@types/react@18.3.3"
import 'npm:react@18.3.1';
// @deno-types="npm:@types/react-dom@18.3.0"
import 'npm:react-dom@18.3.1'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})

execute the following command:

deno run -A --node-modules-dir npm:vite@5 dev

will work as expected, however the if I change the version to v6, vite will throw an error.

deno run -A --node-modules-dir npm:vite@6 dev
TypeError: [ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader.

System Info

vite v6.0.1
deno v2.0.6

Used Package Manager

N/A

Logs

No response

Validations

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