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/configuration.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
title: Configuration
3
3
---
4
4
5
-
`ts-node` supports a variety of options which can be specified via `tsconfig.json`, as CLI flags, as environment variables, or programmatically.
5
+
ts-node supports a variety of options which can be specified via `tsconfig.json`, as CLI flags, as environment variables, or programmatically.
6
6
7
7
For a complete list, see [Options](./options.md).
8
8
9
9
## CLI flags
10
10
11
-
`ts-node` CLI flags must come *before* the entrypoint script. For example:
11
+
ts-node CLI flags must come *before* the entrypoint script. For example:
12
12
13
13
```shell
14
14
$ ts-node --project tsconfig-dev.json say-hello.ts Ronald
@@ -17,7 +17,7 @@ Hello, Ronald!
17
17
18
18
## Via tsconfig.json (recommended)
19
19
20
-
`ts-node` automatically finds and loads `tsconfig.json`. Most `ts-node` options can be specified in a `"ts-node"` object using their programmatic, camelCase names. We recommend this because it works even when you cannot pass CLI flags, such as `node --require ts-node/register` and when using shebangs.
20
+
ts-node automatically finds and loads `tsconfig.json`. Most ts-node options can be specified in a `"ts-node"` object using their programmatic, camelCase names. We recommend this because it works even when you cannot pass CLI flags, such as `node --require ts-node/register` and when using shebangs.
21
21
22
22
Use `--skip-project` to skip loading the `tsconfig.json`. Use `--project` to explicitly specify the path to a `tsconfig.json`.
[@tsconfig/bases](https://github.com/tsconfig/bases) maintains recommended configurations for several node versions.
58
-
As a convenience, these are bundled with `ts-node`.
58
+
As a convenience, these are bundled with ts-node.
59
59
60
60
```json title="tsconfig.json"
61
61
{
@@ -68,7 +68,7 @@ As a convenience, these are bundled with `ts-node`.
68
68
69
69
### Default config
70
70
71
-
If no `tsconfig.json` is loaded from disk, `ts-node` will use the newest recommended defaults from
71
+
If no `tsconfig.json` is loaded from disk, ts-node will use the newest recommended defaults from
72
72
[@tsconfig/bases](https://github.com/tsconfig/bases/) compatible with your `node` and `typescript` versions.
73
73
With the latest `node` and `typescript`, this is [`@tsconfig/node16`](https://github.com/tsconfig/bases/blob/master/bases/node16.json).
74
74
@@ -78,15 +78,15 @@ When in doubt, `ts-node --show-config` will log the configuration being used, an
78
78
79
79
## `node` flags
80
80
81
-
[`node` flags](https://nodejs.org/api/cli.html) must be passed directly to `node`; they cannot be passed to the `ts-node` binary nor can they be specified in `tsconfig.json`
81
+
[`node` flags](https://nodejs.org/api/cli.html) must be passed directly to `node`; they cannot be passed to the ts-node binary nor can they be specified in `tsconfig.json`
82
82
83
83
We recommend using the [`NODE_OPTIONS`](https://nodejs.org/api/cli.html#cli_node_options_options) environment variable to pass options to `node`.
Copy file name to clipboardExpand all lines: website/docs/how-it-works.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: How It Works
3
3
---
4
4
5
-
`ts-node` works by registering hooks for `.ts`, `.tsx`, `.js`, and/or `.jsx` extensions.
5
+
ts-node works by registering hooks for `.ts`, `.tsx`, `.js`, and/or `.jsx` extensions.
6
6
7
7
Vanilla `node` loads `.js` by reading code from disk and executing it. Our hook runs in the middle, transforming code from TypeScript to JavaScript and passing the result to `node` for execution. This transformation will respect your `tsconfig.json` as if you had compiled via `tsc`.
8
8
@@ -12,7 +12,7 @@ Vanilla `node` loads `.js` by reading code from disk and executing it. Our hook
12
12
13
13
> **Warning:** if a file is ignored or its file extension is not registered, node will either fail to resolve the file or will attempt to execute it as JavaScript without any transformation. This may cause syntax errors or other failures, because node does not understand TypeScript type syntax nor bleeding-edge ECMAScript features.
14
14
15
-
> **Warning:** When `ts-node` is used with `allowJs`, all non-ignored JavaScript files are transformed using the TypeScript compiler.
15
+
> **Warning:** When ts-node is used with `allowJs`, all non-ignored JavaScript files are transformed using the TypeScript compiler.
| Transforms `import` into `require()`| Does not transform `import`|
13
13
| Node executes scripts using the classic [CommonJS loader](https://nodejs.org/dist/latest-v16.x/docs/api/modules.html)| Node executes scripts using the new [ESM loader](https://nodejs.org/dist/latest-v16.x/docs/api/esm.html)|
14
-
| Use any of:<br/>`ts-node` CLI<br/>`node -r ts-node/register`<br/>`NODE_OPTIONS="ts-node/register" node`<br/>`require('ts-node').register({/* options */})`| Must use the ESM loader via:<br/>`node --loader ts-node/esm`<br/>`NODE_OPTIONS="--loader ts-node/esm" node`|
14
+
| Use any of:<br/>ts-node CLI<br/>`node -r ts-node/register`<br/>`NODE_OPTIONS="ts-node/register" node`<br/>`require('ts-node').register({/* options */})`| Must use the ESM loader via:<br/>`node --loader ts-node/esm`<br/>`NODE_OPTIONS="--loader ts-node/esm" node`|
15
15
16
16
## CommonJS
17
17
@@ -32,7 +32,7 @@ Transforming to CommonJS is typically simpler and more widely supported because
32
32
}
33
33
```
34
34
35
-
If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool, you can set an override for `ts-node`.
35
+
If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool, you can set an override for ts-node.
36
36
37
37
```json title="tsconfig.json"
38
38
{
@@ -49,7 +49,7 @@ If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool,
49
49
50
50
## Native ECMAScript modules
51
51
52
-
[Node's ESM loader hooks](https://nodejs.org/api/esm.html#esm_experimental_loaders) are [**experimental**](https://nodejs.org/api/documentation.html#documentation_stability_index) and subject to change. `ts-node`'s ESM support is as stable as possible, but it relies on APIs which node can *and will* break in new versions of node. Thus it is not recommended for production.
52
+
[Node's ESM loader hooks](https://nodejs.org/api/esm.html#esm_experimental_loaders) are [**experimental**](https://nodejs.org/api/documentation.html#documentation_stability_index) and subject to change. ts-node's ESM support is as stable as possible, but it relies on APIs which node can *and will* break in new versions of node. Thus it is not recommended for production.
53
53
54
54
For complete usage, limitations, and to provide feedback, see [#1007](https://github.com/TypeStrong/ts-node/issues/1007).
Copy file name to clipboardExpand all lines: website/docs/paths.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: |
3
3
paths and baseUrl
4
4
---
5
5
6
-
You can use `ts-node` together with [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths) to load modules according to the `paths` section in `tsconfig.json`.
6
+
You can use ts-node together with [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths) to load modules according to the `paths` section in `tsconfig.json`.
7
7
8
8
```json title="tsconfig.json"
9
9
{
@@ -14,7 +14,7 @@ You can use `ts-node` together with [tsconfig-paths](https://www.npmjs.com/packa
14
14
}
15
15
```
16
16
17
-
## Why is this not built-in to `ts-node`?
17
+
## Why is this not built-in to ts-node?
18
18
19
19
The official TypeScript Handbook explains the intended purpose for `"paths"` in ["Additional module resolution flags"](https://www.typescriptlang.org/docs/handbook/module-resolution.html#additional-module-resolution-flags).
20
20
@@ -23,4 +23,4 @@ The official TypeScript Handbook explains the intended purpose for `"paths"` in
23
23
> It is important to note that the compiler will not perform any of these transformations; it just uses these pieces of information to guide the process of resolving a module import to its definition file.
24
24
25
25
This means `"paths"` are intended to describe mappings that the build tool or runtime *already* performs, not to tell the build tool or
26
-
runtime how to resolve modules. In other words, they intend us to write our imports in a way `node` already understands. For this reason, `ts-node` does not modify `node`'s module resolution behavior to implement `"paths"` mappings.
26
+
runtime how to resolve modules. In other words, they intend us to write our imports in a way `node` already understands. For this reason, ts-node does not modify `node`'s module resolution behavior to implement `"paths"` mappings.
Copy file name to clipboardExpand all lines: website/docs/troubleshooting.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ title: Troubleshooting
4
4
5
5
## Understanding configuration
6
6
7
-
`ts-node` uses sensible default configurations to reduce boilerplate while still respecting `tsconfig.json` if you
7
+
ts-node uses sensible default configurations to reduce boilerplate while still respecting `tsconfig.json` if you
8
8
have one. If you are unsure which configuration is used, you can log it with `ts-node --show-config`. This is similar to
9
9
`tsc --showConfig` but includes `"ts-node"` options as well.
10
10
11
-
`ts-node` also respects your locally-installed `typescript` version, but global installations fallback to the globally-installed
11
+
ts-node also respects your locally-installed `typescript` version, but global installations fallback to the globally-installed
12
12
`typescript`. If you are unsure which versions are used, `ts-node -vv` will log them.
13
13
14
14
```shell
@@ -54,15 +54,15 @@ $ ts-node --show-config
54
54
55
55
## Understanding Errors
56
56
57
-
It is important to differentiate between errors from `ts-node`, errors from the TypeScript compiler, and errors from `node`. It is also important to understand when errors are caused by a type error in your code, a bug in your code, or a flaw in your configuration.
57
+
It is important to differentiate between errors from ts-node, errors from the TypeScript compiler, and errors from `node`. It is also important to understand when errors are caused by a type error in your code, a bug in your code, or a flaw in your configuration.
58
58
59
59
### `TSError`
60
60
61
61
Type errors from the compiler are thrown as a `TSError`. These are the same as errors you get from `tsc`.
62
62
63
63
### `SyntaxError`
64
64
65
-
Any error that is not a `TSError` is from node.js (e.g. `SyntaxError`), and cannot be fixed by TypeScript or `ts-node`. These are bugs in your code or configuration.
65
+
Any error that is not a `TSError` is from node.js (e.g. `SyntaxError`), and cannot be fixed by TypeScript or ts-node. These are bugs in your code or configuration.
Copy file name to clipboardExpand all lines: website/docs/types.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Help! My Types Are Missing!"
3
3
---
4
4
5
-
**TypeScript Node**does _not_ use `files`, `include` or `exclude`, by default. This is because a large majority projects do not use all of the files in a project directory (e.g. `Gulpfile.ts`, runtime vs tests) and parsing every file for types slows startup time. Instead, `ts-node` starts with the script file (e.g. `ts-node index.ts`) and TypeScript resolves dependencies based on imports and references.
5
+
ts-node does _not_ use `files`, `include` or `exclude`, by default. This is because a large majority projects do not use all of the files in a project directory (e.g. `Gulpfile.ts`, runtime vs tests) and parsing every file for types slows startup time. Instead, ts-node starts with the script file (e.g. `ts-node index.ts`) and TypeScript resolves dependencies based on imports and references.
6
6
7
7
For global definitions, you can use the `typeRoots` compiler option. This requires that your type definitions be structured as type packages (not loose TypeScript definition files). More details on how this works can be found in the [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types).
0 commit comments