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

Getting ERR_INVALID_MODULE_SPECIFIER with typescript ESM files #22

Open
thelinuxlich opened this issue May 18, 2021 · 3 comments
Open

Comments

@thelinuxlich
Copy link

I'm using esbuild-register with this command:

{
 "start": "node --experimental-specifier-resolution=node -r dotenv/config -r esbuild-register src/main.ts"
}

It's throwing this error:

internal/process/esm_loader.js:74
     internalBinding('errors').triggerUncaughtException(

 TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "file:///usr/src/app/packages/admin/src/main.ts" 
  at Loader.getFormat (internal/modules/esm/loader.js:117:13)
 at Loader.getModuleJob (internal/modules/esm/loader.js:242:20)
 at Loader.import (internal/modules/esm/loader.js:176:17)
  at Object.loadESM (internal/process/esm_loader.js:68:5) {
 code: 'ERR_INVALID_MODULE_SPECIFIER'
 }

This doesn't happen when I use ts-node/esm instead

@Maxim-Mazurok
Copy link

This started to happen to me with ts-node/esm, haven't tried esbuild-register. Using node 17

@Maxim-Mazurok
Copy link

My issue was solved by updating ts-node, or by using older nodejs version (16.4.1). I think it's related to TypeStrong/ts-node#1522

@sl45sms
Copy link

sl45sms commented Jan 5, 2022

@Maxim-Mazurok same issue here, with the latest ts-node, downgrade from nodejs 17 to 16.
tnx for your info.

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

No branches or pull requests

3 participants