Type: Bug
I am using npx expo start to process one of the many functions, i.e., ImageSourcePropType from Expo. The format for this is { uri: C:\Users\... }. However, I kept on getting
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Error loading Metro config at: C:\Users\${DIR_NAME}\metro.config.js
Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
I have changed the config in node_modules\metro-config\src\loadConfig.js like this:
Instead of
const configModule = await import(absolutePath);
put
// Fix for Windows: convert Windows path to file:// URL for dynamic import
const pathToImport = path.isAbsolute(absolutePath) && process.platform === 'win32'
? (0, _url.pathToFileURL)(absolutePath).href
: absolutePath;
const configModule = await import(pathToImport);
config = await configModule.default;
However, the terminal still doesn't work. This worked for other users but not mine.
npx expo start previously worked when I incorrectly used require(). Please advise.
VS Code version: Code 1.107.1
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
| Item |
Value |
| CPUs |
Intel(R) Core(TM) i7-3630QM CPU @ 2.40GHz (8 x 2395) |
| GPU Status |
2d_canvas: enabled direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off trees_in_viz: disabled_off video_decode: enabled video_encode: unavailable_off webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
Type: Bug
I am using
npx expo startto process one of the many functions, i.e.,ImageSourcePropTypefrom Expo. The format for this is{ uri: C:\Users\... }. However, I kept on gettingI have changed the config in
node_modules\metro-config\src\loadConfig.jslike this:Instead of
const configModule = await import(absolutePath);put
However, the terminal still doesn't work. This worked for other users but not mine.
npx expo startpreviously worked when I incorrectly usedrequire(). Please advise.VS Code version: Code 1.107.1
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
trees_in_viz: disabled_off
video_decode: enabled
video_encode: unavailable_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off