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

ESM struggle #294

Open
ricardo-valero opened this issue May 26, 2022 · 5 comments
Open

ESM struggle #294

ricardo-valero opened this issue May 26, 2022 · 5 comments

Comments

@ricardo-valero
Copy link

ricardo-valero commented May 26, 2022

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
@owenallenaz
Copy link

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?

@privatenumber
Copy link

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.

@owenallenaz
Copy link

@privatenumber Do you mean tsx watch or tsc watch?

@privatenumber
Copy link

privatenumber commented Sep 15, 2022

tsx watch. It's linked in my comment.

@EliseyMartynov
Copy link

@privatenumber thank you for mentioning this package! That really helped

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

4 participants