ts-node
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@cspotcode/source-map-support | 0.8.1 | 30.68 kB | MIT | prod | |
@tsconfig/node10 | 1.0.11 | 2.26 kB | MIT | prod | |
@tsconfig/node12 | 1.0.11 | 1.32 kB | MIT | prod | |
@tsconfig/node14 | 1.0.3 | 1.3 kB | MIT | prod | |
@tsconfig/node16 | 1.0.4 | 1.28 kB | MIT | prod | |
@types/node | 20.12.7 | 1.94 MB | MIT | prod peer | |
acorn-walk | 8.3.2 | 9.29 kB | MIT | prod | |
acorn | 8.11.3 | 122.89 kB | MIT | prod | |
arg | 4.1.3 | 5.23 kB | MIT | prod | |
create-require | 1.1.1 | 2.65 kB | MIT | prod | |
diff | 4.0.2 | 99.91 kB | BSD-3-Clause | prod | |
make-error | 1.3.6 | 4.33 kB | ISC | prod | |
typescript | 5.4.5 | 30.87 MB | Apache-2.0 | prod peer | |
v8-compile-cache-lib | 3.0.1 | 6.24 kB | MIT | prod | |
yn | 3.1.1 | 2.67 kB | MIT | prod |
Ts-node is a TypeScript execution and REPL for Node.js. It provides a runtime environment that transpiles TypeScript into JavaScript on the fly for immediate execution. The key advantage is the ability to directly run TypeScript files on Node.js, making it an ideal tool for TypeScript development and testing. ts-node also supports source maps for easy debugging.
To utilize ts-node, first install it, along with TypeScript, as a local project dependency in your Node.js project:
npm install -D typescript ts-node
You can also install it globally:
npm install -g typescript ts-node
In addition to the standard installation, for certain configurations, you might need tslib
and @types/node
:
npm install -D tslib @types/node
Once installed, you can use ts-node in several ways:
Executing a TypeScript script
ts-node script.ts
Start a TypeScript REPL
ts-node
Execute code directly with TypeScript
ts-node -e 'console.log("Hello, world!")'
Pipe TypeScript scripts for execution
echo 'console.log("Hello, world!")' | ts-node
Create a Shebang in your TypeScript files
#!/usr/bin/env ts-node
console.log("Hello, world!")
The documentation for ts-node can be found on the official TypeStrong website. The website offers a comprehensive guide to the functionality of ts-node, including installation instructions, CLI usage, configuration options, Advanced usage, and more.