Getting ERR_INVALID_MODULE_SPECIFIER with typescript ESM files
thelinuxlich opened this issue · comments
Alisson Cavalcante Agiani commented
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 commented
This started to happen to me with ts-node/esm, haven't tried esbuild-register. Using node 17
Maxim Mazurok commented
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
Panagiotis commented
@Maxim-Mazurok same issue here, with the latest ts-node, downgrade from nodejs 17 to 16.
tnx for your info.