lint-staged: ERR_UNSUPPORTED_ESM_URL_SCHEME on Windows

Description

It looks like you already fixed one of the issues introduced by 12.1.0, but there seems to be another:

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 'c:'

Steps to reproduce

Run the latest (12.1.1) lint-staged on Windows. Let me know if you would like a repository that reproduces the issue.

Debug Logs

expand to view
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 'c:'
    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 dynamicImport (file:///C:/Projects/System7/Slateplan/UI/react-app/node_modules/lint-staged/lib/loadConfig.js:26:11)
    at Object.search (C:\Projects\System7\Slateplan\UI\react-app\node_modules\lilconfig\dist\index.js:126:37)
    at async loadConfig (file:///C:/Projects/System7/Slateplan/UI/react-app/node_modules/lint-staged/lib/loadConfig.js:62:18) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

Environment

  • OS: Windows 11
  • Node.js: 16.13.0
  • lint-staged: 12.1.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Happened to me on MacOS, fix was to bump the node version to 16(for me specifically to 16.13.2)

~I’m getting this in the command line on linux with node 12.18.3…~

10292$ npx lint-staged --help
(node:717910) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
    internalBinding('errors').triggerUncaughtException(
                              ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:698:11)
    at Loader.resolve (internal/modules/esm/loader.js:97:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:243:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:47:40)
    at link (internal/modules/esm/module_job.js:46:36) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

node 12.18.3

That was my problem, needs >= 12.20.0