scarf
scarf3w ago

workaround for ts-node in package.json script

1. many existing projects use package.json script with ts-node. 2. due to https://github.com/denoland/deno/issues/17176 deno can't run them.
"compile:typebox": "ts-node cases/typebox/index.ts cases/typebox/build",
"compile:typebox": "ts-node cases/typebox/index.ts cases/typebox/build",
have anyone found workaround to run this? i've considered
// replace ts-node with run.sh in scripts
#!/bin/sh

case $JS_RUNNER in
"deno") deno run -A $@ ;;
"bun" ) bunx $@ ;;
* ) npx ts-node $@ ;;
esac
// replace ts-node with run.sh in scripts
#!/bin/sh

case $JS_RUNNER in
"deno") deno run -A $@ ;;
"bun" ) bunx $@ ;;
* ) npx ts-node $@ ;;
esac
but it complicates everything. related: https://github.com/denoland/deno/issues/27166 this is esp. problematic as existing node project still needs ts-node. if only there were a way to shim ts-node to deno...
GitHub
npm:ts-node doesn't work in Deno · Issue #17176 · denoland/deno
deno run -A npm:ts-node error: Uncaught Error: Empty filepath. at pathDirname (deno:ext/node/02_require.js:50:13) at new Module (deno:ext/node/02_require.js:255:17) at Function.Module._resolveFilen...
GitHub
deno task: cannot run tsx · Issue #27166 · denoland/deno
Version: Deno 2.1.2 This is the same error as #20625, but not in the same context. Trying to create an alias for npx tsx --test (to test codebase on node js) but for some reason when executed throu...
2 Replies
marvinh.
marvinh.3w ago
You can do this as a workaround:
- ts-node cases/typebox/index.ts cases/typebox/build
+ deno run -A cases/typebox/index.ts cases/typebox/build
- ts-node cases/typebox/index.ts cases/typebox/build
+ deno run -A cases/typebox/index.ts cases/typebox/build
scarf
scarfOP2w ago
i cannot, it won't work in node and bun environment. i'm currently using npx ts-node as workaround.

Did you find this page helpful?