Node TypeScript Boilerplate

From Logic Wiki
Jump to: navigation, search


npm init
npm  i --save express dotenv
npm i -D mocha chai typescript nodemon supertest ts-node tsconfig-paths
npm i -D @types/chai @types/mocha @types/node @types/supertest @types/express

in package.json add the lines below under scripts

  "scripts": {
    "build": "tsc -p .",
    "dev": "NODE_ENV=dev nodemon -r tsconfig-paths/register src/app.ts",
tsc --init

in tsconfig.json uncomment and change these lines below

"outDir": "./dist", 
"rootDir": "./src",  
"moduleResolution": "node", 
"baseUrl": "./src",  

in package.json add the lines below under scripts

    "test": "NODE_ENV=test mocha --check-leaks -r tsconfig-paths/register -r ts-node/register \"test/**/*.spec.ts\""