-
Make sure tsc is installed
npm install -g typescript
-
cd to an empty dir
-
npm init -y
(will createpackage.json
) -
extend one of the @tsconfig/base configs in
tsconfig.json
tsconfig.json{ "extends": "@tsconfig/node16/tsconfig.json", "include": ["src/**/*"], // (1) "exclude": ["node_modules", "**/*.spec.ts"], "compilerOptions": { "outDir": "./dist/" // (2) } }
-
input files are in
src
-
Specifying output dir not to mix generated code with
.ts
files.
-
-
install
ts-node-dev
npm i -D ts-node-dev+
-
Add to
package.json
{ "scripts": { "start": "tsnd --inspect=0.0.0.0:9229 --respawn --log-error ./src/app.ts", } }
-
Install
tsconfig-paths
npm i -D tsconfig-paths
-
When running
tsnd
, provide-r tsconfig-paths/register
{ "scripts": { "start-with-tsconfig-path": "tsnd --inspect=0.0.0.0:9229 --respawn --log-error -r tsconfig-paths/register ./src/app.ts", } }