deno icon indicating copy to clipboard operation
deno copied to clipboard

Support npm:tsx (esbuild)

Open birkskyum opened this issue 2 years ago • 4 comments

tsx - GitHub

This compiler is used many places in peoples package.json scripts, so it would be great if deno is able to execute it, until it's replaced with i.e. deno everywhere.

Platform

Darwin 22.6.0 arm64 arm

Version

deno 1.37.0

Repro

// index.ts
console.log("Print this");
  • deno run npm:tsx index.ts

It actually breaks even without a file provided, so just deno run npm:tsx;

Expected

> Print this

Actual

➜ deno run npm:tsx index.  
error: Uncaught TypeError: ws.WriteStream.prototype.hasColors is not a function
    at file:///Users/admin/repos/compile-with-tsx/node_modules/.deno/[email protected]/node_modules/tsx/dist/cli.js:18:332

birkskyum avatar Sep 21 '23 18:09 birkskyum

https://github.com/privatenumber/tsx/blob/2c829258a6ca238b7a22c85cc8a09a531267d472/src/run.ts#L39-L40

tsx depends on --require with a preflight CJS.

littledivy avatar Mar 07 '24 04:03 littledivy

The missing hasColors method error is resolved in main and it fails now with this error:

error: unexpected argument '--require' found

  tip: a similar argument exists: '--quiet'

Usage: deno run --allow-all --quiet [SCRIPT_ARG]...

For more information, try '--help'.

marvinhagemeister avatar Jul 22 '24 06:07 marvinhagemeister

deno 2.0.0-rc.2+aaf2bf4

> deno run -A npm:tsx index.ts

error: unexpected argument '--require' found

  tip: to pass '--require' as a value, use '-- --require'

Usage: deno run [OPTIONS] [SCRIPT_ARG]...

birkskyum avatar Sep 18 '24 00:09 birkskyum

@marvinhagemeister , is this likely to be upsteam issue with the flag similar to the tauri issue here?

  • https://github.com/denoland/deno/issues/25904

birkskyum avatar Oct 18 '24 22:10 birkskyum

I am experiencing similar issue with latest vitest (v4) on deno: https://github.com/h3js/srvx/pull/138 (reported to https://github.com/vitest-dev/vitest/issues/8896)

pi0 avatar Oct 31 '25 17:10 pi0