-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js v20.6+ no longer supports the loader API in favour of the register API #743
Comments
--loader
argument
You can create a file to register import {register} from 'node:module';
import { pathToFileURL } from "node:url";
register('@swc-node/register/esm', pathToFileURL('./')); And use it in the
|
Not wanting to create an extra entrypoint file I've found the inline option to work fine as well. {
"scripts": {
"dev": "node --import 'data:text/javascript,import {register} from \"node:module\";import {pathToFileURL} from \"node:url\";register(\"%40swc-node/register/esm\",pathToFileURL(\"./\"));' src/main.ts"
}
} This does make it quite verbose I hope a solution will emerge that lets us do this with a shorter syntax. |
I have created a pr to support this #748 before merged, try use https://npmjs.com/swc-register-esm temporary |
Note: looks like they backported it, because node 18 also emits this warning. |
According to the node.js release notes for node 20.6 the
experimental loaders
API was deprecated in favour of theregister
API.Because of that, we need to use
node --import register.js file.ts
instead ofnode --loader @swc-node/register/esm file.ts
.Currently, it's not possible or not mentioned in the docs how to solve this issue with
@swc-node/register
and the error the users may have isReproduction and workaround
I've added a repo with the reproduction and possible workaround influenced by tsx.
The text was updated successfully, but these errors were encountered: