Code Monkey home page Code Monkey logo

collectibles-nodejs's Introduction

Node-Typescript

Steps to Initiate Typescript With Node

Step 1

  • Run sudo npm i -g typescript to install typescript globally.
  • Check typescripe version by running tsc --version to make sure you installed it correctly.

Step 2

  • Create a file called app.ts touch app.ts
  • Write typescript code in it.
  • To compile it run tsc app.ts. It will generate actual Javascript file for app.js.
  • If you want to watch your ts file everytime when changes happen, run tsc app.ts -w.

Step 3

  • Create a typescript config file by running tsc --init. This will generate a tsconfig.json file with commented options.
  • Make the "target" to es2016
  • Uncomment "outDir": "./" and "rootDir": "./".
  • Add ./dist to outDir. "outDir": "./dist": It will add the compiled js files into dist folder.
  • Add ./src to rootDir. "rootDir": "./src": It will specify the root directory of input files.
  • Make sure to uncomment the "moduleResolution": "node"

Step 4

  • Now move the app.ts file into src folder.
  • Simple run tsc in project directory to automatically create dist folder and add the compiled version of app.ts.

Step 5

  • Add package.json file by running npm init -y.
  • Install express: npm i express.
  • Run npm i -D typescript ts-node nodemon @types/node @types/express to install typescript, ts-node, nodemon, types definition of node and express as Dev dependencies.

Step 6

Add Below as Scripts in package.json file

  • "start":"node dist/app.js",
  • "dev": "nodemon src/app.ts",
  • "build": "tsc -p ."

collectibles-nodejs's People

Contributors

syborg2290 avatar

Watchers

 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.