Skip to content

Latest commit

 

History

History
35 lines (32 loc) · 602 Bytes

File metadata and controls

35 lines (32 loc) · 602 Bytes

Node.js typescript

  1. Init the app
yarn init
  1. Install requirements
yarn add typescript ts-node @types/node && mkdir src && touch src/app.ts 
  1. Add "type": "module" to package.json

  2. tsconfig.json should have the following options:

{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ESNext",
    "moduleResolution": "Node"
  }
}
  1. 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