Skip to content

Import failure on file path with spaces #9917

@clarkdo

Description

@clarkdo

Describe the bug

Related issue: nitrojs/nitro#448 and vitest-dev/vitest#1937

When importing a module path with spaces, vite-node will throw Error: [vite-node] Failed to load, but it works fine in node env.

This works in Node.js:

const util = await import("file:///test/test%20dir/util.mjs")
console.log(util) // 123

But when we import this file in vitest, we'll see error:

import { describe } from 'vitest'

describe('test:suite', async () => {
  const util = await import("file:///test/test%20dir/util.mjs") // Error: [vite-node] Failed to load /test/test%20dir/util.mjs
  console.log(util)
})

Reproduction

https://github.com/clarkdo/vest-import-with-spaces-issue

System Info

System:
    OS: macOS 12.5.1
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0
    npm: 8.15.0
  Browsers:
    Chrome: 104.0.5112.101
  npmPackages:
    vitest: ^0.22.1 => 0.22.1

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions