node-dev
node-dev copied to clipboard
ESM struggle
Hi, in my package.json
I have two scripts, my start
script is working, but dev
using node-dev
isn't
{
"scripts": {
"dev": "node-dev --experimental-specifier-resolution=node --loader ts-node/esm/transpile-only src/index.ts",
"start": "node --experimental-specifier-resolution=node --loader ts-node/esm/transpile-only src/index.ts",
},
//...
}
I'm trying to work with ESM, because I need top level await
This is the error:
[ERROR] 19:34:14 RangeError: Unknown module format: null for URL file:///path_to_project/src/index.ts
I'm struggling here trying to get node-dev
to work with esm. I've tried using ts-node-dev
, now I've tried node-dev
and it's just been hours of struggles.
Does anyone have a recipe of the changes needed in package.json, tsconfig.json and commands that allow us to have watching/reloading in node-dev?
Recommending using tsx watch
here.
It's like node-dev
in that also only watches files that are imported, but it also supports native ESM.
@privatenumber Do you mean tsx watch
or tsc watch
?
tsx watch
. It's linked in my comment.
@privatenumber thank you for mentioning this package! That really helped