-
-
Notifications
You must be signed in to change notification settings - Fork 536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
changed all references to ts-node consistent #1481
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ Here is a brief comparison of the two. | |
| Write native `import` syntax | Write native `import` syntax | | ||
| Transforms `import` into `require()` | Does not transform `import` | | ||
| 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) | | ||
| 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` | | ||
| 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` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be in backticks since it refers to the binary's name? |
||
|
||
## CommonJS | ||
|
||
|
@@ -32,7 +32,7 @@ Transforming to CommonJS is typically simpler and more widely supported because | |
} | ||
``` | ||
|
||
If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool, you can set an override for `ts-node`. | ||
If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool, you can set an override for ts-node. | ||
|
||
```json title="tsconfig.json" | ||
{ | ||
|
@@ -49,7 +49,7 @@ If you must keep `"module": "ESNext"` for `tsc`, webpack, or another build tool, | |
|
||
## Native ECMAScript modules | ||
|
||
[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. | ||
[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. | ||
|
||
For complete usage, limitations, and to provide feedback, see [#1007](https://github.com/TypeStrong/ts-node/issues/1007). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ title: Troubleshooting | |
|
||
## Understanding configuration | ||
|
||
`ts-node` uses sensible default configurations to reduce boilerplate while still respecting `tsconfig.json` if you | ||
ts-node uses sensible default configurations to reduce boilerplate while still respecting `tsconfig.json` if you | ||
have one. If you are unsure which configuration is used, you can log it with `ts-node --show-config`. This is similar to | ||
`tsc --showConfig` but includes `"ts-node"` options as well. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto previous comment about "ts-node" as JSON syntax. |
||
`tsc --showConfig` but includes "ts-node" options as well. | ||
|
||
`ts-node` also respects your locally-installed `typescript` version, but global installations fallback to the globally-installed | ||
ts-node also respects your locally-installed `typescript` version, but global installations fallback to the globally-installed | ||
`typescript`. If you are unsure which versions are used, `ts-node -vv` will log them. | ||
|
||
```shell | ||
|
@@ -54,15 +54,15 @@ $ ts-node --show-config | |
|
||
## Understanding Errors | ||
|
||
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. | ||
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. | ||
|
||
### `TSError` | ||
|
||
Type errors from the compiler are thrown as a `TSError`. These are the same as errors you get from `tsc`. | ||
|
||
### `SyntaxError` | ||
|
||
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. | ||
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. | ||
|
||
#### Unsupported JavaScript syntax | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,14 +42,14 @@ Passing CLI arguments via shebang is allowed on Mac but not Linux. For example, | |
// This shebang is not portable. It only works on Mac | ||
``` | ||
|
||
Instead, specify all `ts-node` options in your `tsconfig.json`. | ||
Instead, specify all ts-node options in your `tsconfig.json`. | ||
|
||
## Programmatic | ||
|
||
You can require `ts-node` and register the loader for future requires by using `require('ts-node').register({ /* options */ })`. You can also use file shortcuts - `node -r ts-node/register` or `node -r ts-node/register/transpile-only` - depending on your preferences. | ||
You can require ts-node and register the loader for future requires by using `require('ts-node').register({ /* options */ })`. You can also use file shortcuts - `node -r ts-node/register` or `node -r ts-node/register/transpile-only` - depending on your preferences. | ||
|
||
**Note:** If you need to use advanced node.js CLI arguments (e.g. `--inspect`), use them with `node -r ts-node/register` instead of the `ts-node` CLI. | ||
**Note:** If you need to use advanced node.js CLI arguments (e.g. `--inspect`), use them with `node -r ts-node/register` instead of the ts-node CLI. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto question about |
||
|
||
### Developers | ||
|
||
`ts-node` exports a `create()` function that can be used to initialize a TypeScript compiler that isn't registered to `require.extensions`, and it uses the same code as `register`. | ||
ts-node exports a `create()` function that can be used to initialize a TypeScript compiler that isn't registered to `require.extensions`, and it uses the same code as `register`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
"ts-node"
should still be in backticks since it's JSON syntax.