node-dev icon indicating copy to clipboard operation
node-dev copied to clipboard

Cannot set config "extension:{ts: 'ts-node/esm'}"

Open kermanx opened this issue 3 years ago • 8 comments

Cannot set config as

  extensions: {
...
    ts: 'ts-node/esm'
  },

If I set it like this, it shows: image

kermanx avatar Jan 31 '22 08:01 kermanx

Hello?

kermanx avatar Feb 03 '22 13:02 kermanx

Looks like you don't have ts-node installed.

bjornstar avatar Feb 03 '22 14:02 bjornstar

Looks like you don't have ts-node installed.

I dont think so...

kermanx avatar Feb 03 '22 14:02 kermanx

https://github.com/fgnass/node-dev/blob/9a36a148bc41cd9deb1efd090e4289368db68ad6/lib/wrap.js#L66

↑ this line use require whether it is MJS or CJS. I wonder whether it is correct. @bjornstar

kermanx avatar Feb 03 '22 14:02 kermanx

Feel free to raise a PR with the fix.

bjornstar avatar Feb 03 '22 14:02 bjornstar

I have no ideas 😥

kermanx avatar Feb 03 '22 14:02 kermanx

I tried to use import, but got more errors... And I've learnt TS/JS for only 0.5 years...

kermanx avatar Feb 03 '22 14:02 kermanx

This is actually a duplicate of #242. From ts-node's docs, their ESM loader must passed as a custom loader:

Use any of: ts-node --esm ts-node-esm Set "esm": true in tsconfig.json node --loader ts-node/esm NODE_OPTIONS="--loader ts-node/esm" node

kherock avatar Mar 27 '22 21:03 kherock