scriptmaster
9/21/2017 - 6:27 AM

ts-node.md

TypeScript node

Use TypeScript with node by installing typescript and @types/node

yarn global add typescript

In your project directory:

mkdir tsapp && cd tsapp

Install nodejs types:

yarn add @types/node

Create a file:


import * as http from 'http';

console.log('server. ts started');

Create tsconfig.json (optional)

using typescript compiler init option:

tsc --init

Run typescript file:

ts-node server.js

Configure with nodemon:

Configure with pm2:

Configuring with webpack (client)

This is for client files only. Not to be mixed with server nodejs scripts. For that ts-node and @types/node should do.

Create webpack.config.js and do:

webpack