Skip to content

Node and TypeScript Setup locally #3

@Type-Style

Description

@Type-Style
  • download & install Node
    npm init -y
  • Install TypeScript & check version
    npm install --save-dev typescript
    npx tsc --version
  • Configure tsconfig
    tsconfig.json
{
  "extends": "@tsconfig/node20/tsconfig.json",
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}
  • Inspect package version for ts setup

  • install compiler options

  • add compiler options

"compilerOptions": {
	"outDir": "dist"
}
  • install types for less errors
    npm install --save-dev @types/node

  • test typescript compiler
    createindex.tscontaining console.log("hello world")
    run npx tsc

  • configure watcher
    npm install --save-dev ts-node nodemon
    nodemon.json

{
  "watch": ["src"],
  "ext": ".ts",
  "ignore": [],
  "exec": "tsc && node dist/server.js"
}
  • prepare debugging
    "compilerOptions": { "sourceMap": true

vscodium debug config

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Debug server.ts",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/src/server.ts",
      "preLaunchTask": "tsc: build - tsconfig.json",
      "outFiles": ["${workspaceFolder}/dist/**/*.js"]
    }
  ]
}

Metadata

Metadata

Assignees

Labels

setupOperational Stuff

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions