Config, Compile and Run TypeScript with Concurrently, Nodemon, & Express

PHOTO EMBED

Sun Nov 08 2020 18:22:03 GMT+0000 (Coordinated Universal Time)

Saved by @robertjbass #typescript #javascript #express #nodejs #bash

// BASH
mkdir src
mkdir build
touch src/index.ts
touch .gitignore
touch README.md
tsc -y
npm init -y
npm install nodemon concurrently @types/express --save-dev

// package.json
...
"scripts": {
  "start:build": "tsc -w",
  "start:run": "nodemon ./build/index.js",
  "start": "concurrently npm:start:*"
},
...

// tsconfig.json
...
"outDir": "./build",
"rootDir": "./src",
...

// .gitignore
node_modules
*.env

// README.md
### Start
```bash
npm run start
```

// src/index.ts
import express from 'express'
const port = 3000
const app = express()

console.log("Hello, World!!!")

logSomething("This is a string that I'm logging")

app.listen(port, () => {
  console.log(`Listening on port ${port}`)
})
content_copyCOPY

BOILERPLATE General config for a TypeScript express app using concurrently and nodemon for development