xxxxxxxxxx
# Execute a script as `node` + `tsc`.
ts-node script.ts
# Starts a TypeScript REPL.
ts-node
# Execute code with TypeScript.
ts-node -e 'console.log("Hello, world!")'
# Execute, and print, code with TypeScript.
ts-node -p -e '"Hello, world!"'
# Pipe scripts to execute with TypeScript.
echo 'console.log("Hello, world!")' | ts-node
# Equivalent to ts-node --transpile-only
ts-node-transpile-only script.ts
# Equivalent to ts-node --cwd-mode
ts-node-cwd script.ts
xxxxxxxxxx
Install ts-node-dev
yarn add ts-node-dev --dev
npm i ts-node-dev --save-dev
So you just combine node-dev and ts-node options (see docs of those packages):
ts-node-dev --respawn --transpile-only server.ts
There is also short alias tsnd for running ts-node-dev:
tsnd --respawn server.ts
ts-node-dev --respawn --transpile-only server.ts
xxxxxxxxxx
ts-node-dev --respawn --transpile-only server.ts
ts-node-dev
xxxxxxxxxx
npm i ts-node-dev --save-dev
//Usage & package.json file set option
ts-node-dev --respawn --transpile-only server.ts