You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-19
Original file line number
Diff line number
Diff line change
@@ -30,22 +30,45 @@ _TypeScript Execute (tsx)_: The easiest way to run TypeScript in Node.js
30
30
</p>
31
31
32
32
## About
33
-
`tsx` is a CLI command (alternative to `node`) for running TypeScript & ESM in both `commonjs` & `module` package types.
33
+
`tsx` is a CLI command you can use just like you would use `node`:
34
34
35
-
tsx is for you if you want:
36
-
- A command to _just run_ TypeScript code without configuration
37
-
- Something so fast it's unnoticeable
38
-
- Seamless integration across ESM and CJS dependencies
35
+
<table>
36
+
<tr>
37
+
<th>Before</th>
38
+
<th>After</th>
39
+
</tr>
40
+
<tr>
41
+
<td>
42
+
43
+
```sh
44
+
node file.js
45
+
```
46
+
47
+
</td>
48
+
<td>
49
+
50
+
```sh
51
+
tsx file.js
52
+
```
53
+
54
+
</td>
55
+
</tr>
56
+
</table>
39
57
40
-
If you're getting the following error, give tsx a try!
58
+
59
+
Use it to enhance your Node.js experience:
60
+
-_Just run_ TypeScript code without configuration
61
+
- Seamless integration between CommonJS and ES Modules
62
+
63
+
You'll never get the following error again:
41
64
42
65
```
43
66
Error [ERR_REQUIRE_ESM]: require() of ES Module <ESM package> from ./file.js not supported.
44
67
Instead change the require of <ESM package> in ./file.js to a dynamic import() which is available in all CommonJS modules.
45
68
```
46
69
47
70
### ⚡️ Quick start
48
-
Try it out without setup! Just pass in a TypeScript file:
71
+
Try it out without setup using [npx](https://docs.npmjs.com/cli/v8/commands/npx)! Just pass in a TypeScript file:
49
72
50
73
```sh
51
74
npx tsx ./script.ts
@@ -86,26 +109,25 @@ npm install --global tsx
86
109
Then, you can call `tsx` directly:
87
110
88
111
```sh
89
-
tsx ...
112
+
tsx file.ts
90
113
```
91
114
92
-
## Usage
93
-
94
-
### tsx is a Node.js wrapper
115
+
Now you can replace `node ...` with `tsx ...` in all your commands!
95
116
96
-
_tsx_ wraps around Node.js to enhance it with TypeScript support. Because it's a drop-in replacement for `node`, it supports all [Node.js command-line flags](https://nodejs.org/docs/latest-v20.x/api/cli.html).
117
+
## Usage
97
118
98
-
```sh
99
-
# --no-warnings is a Node.js flag
100
-
tsx --no-warnings ./file.ts
101
-
```
119
+
### Swap `node` out for `tsx`
102
120
103
-
### Run TypeScript / ESM / CJS module
121
+
_tsx_ is an enhanced version of Node.js. If you have a `node ...` command, you can replace the `node` with `tsx` and it will just work.
104
122
105
-
Pass in a file to run:
123
+
Because it's a drop-in replacement for `node`, it supports all [Node.js command-line flags](https://nodejs.org/docs/latest-v20.x/api/cli.html).
0 commit comments