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: website/docs/usage.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,14 +35,27 @@ ts-node-cwd script.ts
35
35
console.log("Hello, world!")
36
36
```
37
37
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`.
39
39
40
+
```typescript
41
+
#!/usr/bin/env-Sts-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
40
44
```
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/envts-node
50
+
// This shebang works everywhere
43
51
```
44
52
45
-
Instead, specify all ts-node options in your `tsconfig.json`.
0 commit comments