DEV Community

Sid Kiwi
Sid Kiwi

Posted on

Resolving ERR_UNSUPPORTED_ESM_URL_SCHEME

I've been getting back into Node development lately, specifically working on a SvelteKit+Skeleton+Tailwind app. I recently upgraded to a new Mac and started running into a strange issue:

✗ npm install
npm ERR! code 1
npm ERR! path /..../node_modules/@vercel/speed-insights
npm ERR! command failed
npm ERR! command sh -c node scripts/postinstall.mjs
npm ERR! internal/process/esm_loader.js:74
npm ERR!     internalBinding('errors').triggerUncaughtException(
npm ERR!                               ^
npm ERR!
npm ERR! Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. Received protocol 'node:'
npm ERR!     at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:782:11)
npm ERR!     at Loader.resolve (internal/modules/esm/loader.js:85:40)
npm ERR!     at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
npm ERR!     at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:51:40)
npm ERR!     at link (internal/modules/esm/module_job.js:50:36) {
npm ERR!   code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
npm ERR! }

npm ERR! A complete log of this run can be found in: /..../.npm/_logs/2024-02-25T18_59_56_421Z-debug-0.log
Enter fullscreen mode Exit fullscreen mode

This wasn't just with the @vercel/speed-insights package though, and even occurred when creating a brand new Skeleton app, like:

➜  nvm use node
Now using node v20.11.1 (npm v10.4.0)
➜  npm create skeleton-app@latest my-skeleton-app
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. Received protocol 'node:'
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:782:11)
    at Loader.resolve (internal/modules/esm/loader.js:85:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:51:40)
    at link (internal/modules/esm/module_job.js:50:36) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
npm ERR! code 1
npm ERR! path /..../new
npm ERR! command failed
npm ERR! command sh -c create-skeleton-app my-skeleton-app

npm ERR! A complete log of this run can be found in: /..../.npm/_logs/2024-02-25T19_13_17_337Z-debug-0.log
Enter fullscreen mode Exit fullscreen mode

After trying everything I could think of (reinstalling nvm, updating dependencies, reinstalling Homebrew, and much more), I realized I had a ~/node_modules. Removing that solved the issue!

I hope this helps someone.

Top comments (0)