Code Monkey home page Code Monkey logo

node-typescript-template's Introduction

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:*",
}

node-typescript-template's People

Contributors

sernadesigns avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.