- Init the app
yarn init- Install requirements
yarn add typescript ts-node @types/node && mkdir src && touch src/app.ts
-
Add
"type": "module"topackage.json -
tsconfig.jsonshould have the following options:
{
"compilerOptions": {
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Node"
}
}- Run the app with the following command:
node --experimental-specifier-resolution=node --loader ts-node/esm ./src/app.ts
Or
yarn global add ts-node
And Run:
ts-node --esm ./src/app.ts