Skip to content
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

Error: ERR_UNSUPPORTED_ESM_URL_SCHEME for new release on run #8651

Closed
CantisW opened this issue Feb 17, 2022 · 4 comments · Fixed by #8669
Closed

Error: ERR_UNSUPPORTED_ESM_URL_SCHEME for new release on run #8651

CantisW opened this issue Feb 17, 2022 · 4 comments · Fixed by #8669

Comments

@CantisW
Copy link

CantisW commented Feb 17, 2022

Issue Description

Using the new Typeorm release does not work as expected as it keeps giving a ERR_UNSUPPORTED_ESM_URL_SCHEME error.

Expected Behavior

TypeOrm should run as intended.

Actual Behavior

TypeOrm tries to connect to the ormconfig database, then before it can get any further, errors.

The project was created using npx typeorm init --name MyProject --database postgres --module esm

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:1032:11)
    at C:\Users\user\Desktop\random-coding-projects\ProjectFiles\JS\discord-economy-bot-typescript\MyProject\node_modules\ts-node\src\esm.ts:129:23
    at Generator.next (<anonymous>)
    at C:\Users\user\Desktop\random-coding-projects\ProjectFiles\JS\discord-economy-bot-typescript\MyProject\node_modules\ts-node\dist\esm.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\user\Desktop\random-coding-projects\ProjectFiles\JS\discord-economy-bot-typescript\MyProject\node_modules\ts-node\dist\esm.js:4:12)
    at defer (C:\user\user\Desktop\random-coding-projects\ProjectFiles\JS\discord-economy-bot-typescript\MyProject\node_modules\ts-node\src\esm.ts:128:30)
    at C:\Users\user\Desktop\random-coding-projects\ProjectFiles\JS\discord-economy-bot-typescript\MyProject\node_modules\ts-node\src\esm.ts:137:14
    at Generator.next (<anonymous>) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

Steps to Reproduce

  1. Run npx typeorm init --name MyProject --database postgres --module esm
  2. Setup ormconfig.json as normal
  3. Run the project (node start)

My Environment

Dependency ts-node, TypeScript, Typeorm, pg, reflect-metadata
Operating System Windows 10
Node.js version v17.3.0
Typescript version 4.5.5
TypeORM version 0.2.42

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-data-api no
aurora-data-api-pg no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres yes
react-native no
sap no
sqlite no
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
@CantisW CantisW changed the title Error: ERR_UNSUPPORTED_ESM_URL_SCHEME for new release Error: ERR_UNSUPPORTED_ESM_URL_SCHEME for new release on run Feb 17, 2022
@pleerock
Copy link
Member

@giladgd can you please check this out?

@giladgd
Copy link
Contributor

giladgd commented Feb 17, 2022

@CantisW @pleerock I've tried reproducing it on both macOS and Windows 11 but this issue didn't occur to me.
Running npx typeorm init --name MyProject --database postgres --module esm produces a valid project, running npm start in the newly generated folder works properly.

@CantisW
Copy link
Author

CantisW commented Feb 18, 2022

Super strange. The issue makes Typeorm completely unusable on ESM projects, but it still works fine on non-ESM projects.

Turning on logging gives
query: SELECT * FROM current_schema()
showing that it's doing something.

Do you guys potentially have any suggestions on what to do to work around this issue?

@giladgd
Copy link
Contributor

giladgd commented Feb 18, 2022

@pleerock @CantisW After some more rigorous testing on Windows I found the problem that you're experiencing, though not through the generated project.
It appears to be specific to ESM projects running on Windows, and it doesn't happen with every configuration which made it harder for me to replicate.
I've opened #8669 to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants