How to use ts-node esm loader with npx? #1463
-
A follow-up to #1007 (comment) question: Is there any way to use ts-node esm loader with Perhaps, you could make Or is there any way I can specify something like
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I think the problem is that npx will install and run an executable into a non-local location controlled by npx, but the working directory is local. Node's This is why the following:
Will raise an error We have a ticket for this: #1258 That ticket proposes the addition of a new executable:
|
Beta Was this translation helpful? Give feedback.
-
For what it's worth, I experienced the same error trying to use
For my particular solution, |
Beta Was this translation helpful? Give feedback.
I think the problem is that npx will install and run an executable into a non-local location controlled by npx, but the working directory is local. Node's
--loader
flag attempts toimport
the loader, which will be done locally unless it is an absolute path.This is why the following:
Will raise an error
Cannot find package 'ts-node'
.ts-node
cannot be found in the working directory.We have a ticket for this: #1258
That ticket proposes the addition of a new executable:
ts-node-esm
which can be used as follows: