question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error with esm on windows

See original GitHub issue

I was following @mcollina tutorial for Fastify, and I faced with an error related to fastify-autoload plugin:

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:781:11)
    at Loader.resolve (internal/modules/esm/loader.js:85:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:229:28)
    at Loader.import (internal/modules/esm/loader.js:164:28)
    at importModuleDynamically (internal/modules/cjs/loader.js:1199:27)
    at exports.importModuleDynamicallyCallback (internal/process/esm_loader.js:30:14)
    at loadPlugin (C:\Users\amis\Desktop\fastify3-test\node_modules\fastify-autoload\index.js:117:5)
    at C:\Users\amis\Desktop\fastify3-test\node_modules\fastify-autoload\index.js:27:12
    at Array.map (<anonymous>)
    at fastifyAutoload (C:\Users\amis\Desktop\fastify3-test\node_modules\fastify-autoload\index.js:26:29) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

I’m running Node v14.7.0 on Windows 10. This is how the app looks like:

app.js
import fastify from 'fastify'
import autoload from 'fastify-autoload'
import { join } from 'desm'

export default function (opts) {
    const app = fastify(opts)

    app.register(autoload, {
        dir: join(import.meta.url, 'routes')
    })

    return app
}
/routes/hello.js
export default async function (app) {
    app.get('/', async function (req, rep) {
        return { hello: 'world' }
    })
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (25 by maintainers)

github_iconTop GitHub Comments

1reaction
mcollinacommented, Aug 13, 2020

@StarpTech can you open an issue on node core on this and tag me on it? Thanks. This is very confusing.

1reaction
StarpTechcommented, Aug 13, 2020

Because in Linux a path is a valid file URL? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES Module loading with abolute path fails on windows #31710
Version: v13.8.0; Platform: Windows 10 64-bit version 1809; Subsystem: "esm" maybe? What steps will reproduce the bug?
Read more >
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 ...
Read more >
Tools and tips used for troubleshooting ESM status problems
In this post, we will cover general troubleshooting of ESM "status" ... If you get an error here, your WMI service is not...
Read more >
Lab 7.1 ERR_UNSUPPORTED_ESM_URL_SCHEME
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be ...
Read more >
112E ESM Module number ("name") returned error code value ...
The ESM Module name (at position number in the stack, if multiple modules are configured) returned error code value from an Xauth (authorize...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found