Error on launch: "Only file and data URLs are supported by the default ESM loader"
See original GitHub issueHey! So I’m trying to set up Peeky for my current project.
I’m on Windows 11 with:
- node 16.13.1 (LTS)
- vue 3.2.26 (latest)
- vite 2.7.5 (latest)
- @peeky/test 0.9.3 (latest)
The project works with vite dev
and vite build
. Jest and Vitest works flawlessly.
But in the same project, when I launch peeky test
I get this error:
ERROR Running tests failed: Error: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'(/node_modules/lodash/lodash.js) (/src/modules/application/lib/treeDoc.ts) (/@fs/D:/Library/Projects/LunaPark/frontend/src/modules/application/lib/treeDoc.spec.ts)
at new NodeError (node:internal/errors:371:5)
at defaultResolve (node:internal/modules/esm/resolve:1016:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:111:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at cachedRequest (file:///D:/Library/Projects/LunaPark/frontend/node_modules/@peeky/runner/src/runtime/vite.ts:105:38)
at D:/Library/Projects/LunaPark/frontend/src/modules/application/lib/treeDoc.ts:1:281
at rawRequest (file:///D:/Library/Projects/LunaPark/frontend/node_modules/@peeky/runner/src/runtime/vite.ts:210:7)
It seems to be triggered when I import lodash (and lodash probably import some other thing with an absolute path)
I’m still not quite sure if it’s a Peeky bug, a Vite bug, or just me forgetting to update some configuration, but I can’t find anything on that ESM Loader…
Here is my vite.config.ts
file if it helps:
import * as path from "path";
import { defineConfig, UserConfig } from "vite";
import vue from "@vitejs/plugin-vue";
const alias = {
"@": path.resolve(__dirname, "src")
};
export default defineConfig(({ command }) => {
const config: UserConfig = {
plugins: [vue()],
resolve: {
alias
},
server: {
port: 8080
},
test: {
runtimeEnv: "dom"
}
};
if (command === "build") {
config.base = "/static/";
}
return config;
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file ...
ERROR 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 ...
Read more >Only file and data URLs are supported by the default ESM ...
[BUG] 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:// ......
Read more >Only file and data URLs are supported by the default ESM ...
I am trying to run a nodejs app in cluster mode, but it always ends in the same error code [ERR_UNSUPPORTED_ESM_URL_SCHEME] . This...
Read more >Copy-webpack-plugin causes build failure on netlify - Support
Adding copy-webpack-plugin causes build failure in netlify. They use import() to load ESM dependencies, looks like your env is not supported it.
Read more >Doug Midgley's Feed | Salesforce Trailblazer Community
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:// ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Akryum Here it is: https://github.com/hugoattal/peeky-bug-reproduction
npm install
npm run test
Also happens with yarn btw