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
* Note `skip-ignore` for "Skipping `node_modules`" (#1553)
* Note `skip-ignore` for "Skipping `node_modules`"
* Remove spurious duplication
* update
* revert changes to readme; readme is built from docs/
* more wordsmithing
* more tweaks
Co-authored-by: Andrew Bradley <[email protected]>
* Passing arguments in shebang on Linux (env -S) (#1545)
* Passing arguments in shebang on Linux (env -S)
It is possible to pass arguments into commands in the shebang on Linux using the env(1) -S option.
* fix
* fix
* fix
Co-authored-by: Andrew Bradley <[email protected]>
* link from readme logo to website (#1604)
Co-authored-by: webstrand <[email protected]>
Co-authored-by: wmb <[email protected]>
Copy file name to clipboardExpand all lines: website/docs/how-it-works.md
+8-1
Original file line number
Diff line number
Diff line change
@@ -16,9 +16,16 @@ Vanilla `node` loads `.js` by reading code from disk and executing it. Our hook
16
16
17
17
## Skipping `node_modules`
18
18
19
-
By default, **TypeScript Node** avoids compiling files in `/node_modules/` for three reasons:
19
+
By default, ts-node avoids compiling files in `/node_modules/` for three reasons:
20
20
21
21
1. Modules should always be published in a format node.js can consume
22
22
2. Transpiling the entire dependency tree will make your project slower
23
23
3. Differing behaviours between TypeScript and node.js (e.g. ES2015 modules) can result in a project that works until you decide to support a feature natively from node.js
24
24
25
+
If you need to import uncompiled TypeScript in `node_modules`, use [`--skipIgnore`](./options#transpilation) or [`TS_NODE_SKIP_IGNORE`](./options#transpilation) to bypass this restriction.
26
+
27
+
## Skipping pre-compiled TypeScript
28
+
29
+
If a compiled JavaScript file with the same name as a TypeScript file already exists, the TypeScript file will be ignored. ts-node will import the pre-compiled JavaScript.
30
+
31
+
To force ts-node to import the TypeScript source, not the precompiled JavaScript, use [`--preferTsExts`](./options#transpilation).
Copy file name to clipboardExpand all lines: website/docs/usage.md
+17-4
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 available on recent versions of `env`. ([compatibility](https://github.com/TypeStrong/ts-node/pull/1448#issuecomment-913895766))
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