Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import files into vite.config.ts on Windows with "type": "module" in package.json #9471

Closed
7 tasks done
SilentEchoGM opened this issue Jul 31, 2022 · 0 comments · Fixed by #9473
Closed
7 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) windows only

Comments

@SilentEchoGM
Copy link

Describe the bug

On Windows, in a project with "type": "module" set in package.json, I am unable to import a shared config into vite.config.ts without receiving a ERR_UNSUPPORTED_ESM_URL_SCHEME error. This appears to be the same issue that #1712 refers to but it seems the fix implemented for that missed the imported file paths.

Discussed on Discord here: https://discord.com/channels/804011606160703521/814182556068085760/1003178053779865640

Reproduction

https://github.com/SilentEchoUK/esm-url-vite-repro

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 17.39 GB / 31.93 GB
  Binaries:
    Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.11.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.77)
    Internet Explorer: 11.0.22000.120

Used Package Manager

pnpm

Logs

failed to load config from D:\scratch\vite-repro\vite-package\vite.config.ts
error during build:
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at new NodeError (node:internal/errors:371:5)
    at throwIfUnsupportedURLProtocol (node:internal/modules/esm/resolve:1033:11)
    at defaultResolve (node:internal/modules/esm/resolve:1103:3)
    at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:79:40)
    at link (node:internal/modules/esm/module_job:78:36)

Validations

sapphi-red added a commit to sapphi-red/vite that referenced this issue Jul 31, 2022
@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jul 31, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority) windows only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants