Skip to content

Commit 98970af

Browse files
committed
fix
1 parent f3bced1 commit 98970af

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

website/docs/usage.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,27 @@ ts-node-cwd script.ts
3535
console.log("Hello, world!")
3636
```
3737

38-
Passing CLI arguments via shebang is allowed on Mac but not Linux. For example, the following will fail on Linux:
38+
Passing options via shebang requires the [`env -S` flag](https://manpages.debian.org/bullseye/coreutils/env.1.en.html#S), which is not available on old versions of `env`.
3939

40+
```typescript
41+
#!/usr/bin/env -S ts-node --files
42+
// This shebang works on Mac and Linux with newer versions of env
43+
// Technically, Mac allows omitting `-S`, but Linux requires it
4044
```
41-
#!/usr/bin/env ts-node --files
42-
// This shebang is not portable. It only works on Mac
45+
46+
To write scripts with maximum portability, [specify all options in your `tsconfig.json`](./configuration#via-tsconfigjson-recommended) and omit them from the shebang.
47+
48+
```typescript
49+
#!/usr/bin/env ts-node
50+
// This shebang works everywhere
4351
```
4452

45-
Instead, specify all ts-node options in your `tsconfig.json`.
53+
To test your version of `env` for compatibility:
54+
55+
```shell
56+
# Note that these unusual quotes are necessary
57+
/usr/bin/env --debug '-S echo foo bar'
58+
```
4659

4760
## Programmatic
4861

0 commit comments

Comments
 (0)