ts-node dev in Node.js
Using typescript for Node.js may seems a little annoying at first but when you become familiar you will love it and it becomes unavoidable in some cases. If any required file changes it restarts target node process but between the restarts Typescript compilation process is shared. So the speed of restarting increases remarkably since there is no need to instantiate ts-node compilation each time. To install use npm.
npm i ts-node-dev --save-dev
This is how it is used:
ts-node-dev [node-dev|ts-node flags] [ts-node-dev flags] [node cli flags] [--] [script] [script arguments]
Now you combine ts-node and node-dev as below:
ts-node-dev --respawn --transpileOnly server.ts
There are some additional options like –prefer-ts for each .js file will try to check if respective .ts version is there or not and require it. –ignore-watch is for files or folders to be ignored by node-dev. Then there is –debug for additional debug output and –interval for polling interval, --debounce for debounce file change events, --clear will clear the screen after restart.
Comments
0 comments
Please Sign in or Create an account to Post Comments