Skip to content

sernadesigns/node-typescript-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node Typescript Template

This template is meant to help you get started with a basic node application with a typescript compiler.

Template Creation Steps

Under the hood. These were the steps taken to create this template.

1. Install dependencies globally

yarn global add node typescript

2. Generate package.json file

-y will skip the questions that npm will prompt in the package.json setup. If you would like more control of your setup, omit this flag.

npm init -y

3. Install devDependencies

  • nodemon - A tool for developing node.js applications for automatically restarting the application when file changes are detected
  • concurrently - A tool allowing multiple commands to be run concurrently
yarn add --dev nodemon concurrently

4. Generate tsconfig.json file

Will generate a tsconfig.json file.

tsc --init

5. Generate folder structure

  • src - Directory to contain all source files of the application
  • build - Directory to output compiled files from the typescript compiler
mkdir src build

6. Update tsconfig.json

Informs typescript of the root directory and output directory locations.

{
  "compilerOptions": {
    ...
    // "outFile": "./",
-   // "outDir": "./",
+   "outDir": "./build",
-   // "rootDir": "./",
+   "rootDir": "./src",
    // "composite": true,
    ...
  }
}

7. Configure scripts in package.json

  • start:build - Start up the typescript compiler and watch input files
  • start:run - Start up node server and run build/index.js file
  • start - Run start:build and start:run scripts concurrently
// package.json
scripts: {
  "start:build": "tsc -w",
  "start:run": "nodemon build/index.js",
  "start": "concurrently npm:start:*",
}

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published