Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Setting Up the TypeScript Development Environment

Setting Up the Development Environment

~10 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

Before starting the actual library management project, let's set up the tools we need: Node.js, the TypeScript compiler, and a modern way to run TypeScript files directly, without manually compiling after every change.

Installing Node.js

Node.js is the JavaScript runtime our project builds on – download the current LTS version from nodejs.org, or use a version manager like nvm. Verify the installation:

node --version
npm --version

TypeScript: global vs. project-local

TypeScript CAN be installed globally (npm install -g typescript), but the recommended practice is a PROJECT-LOCAL install – each project can then maintain its own TypeScript version, independent of whatever's installed globally (important when different projects need different TypeScript versions).

tsx: running TypeScript files directly

The classic path would be: compile the .ts file to .js with tsc, THEN run the result with node – two steps on EVERY change. tsx is a modern runner that combines both steps into ONE command: run .ts files directly, compiled "on the fly" in the background.

Creating the library management project

mkdir bibliotheks-app
cd bibliotheks-app
npm init -y
npm install --save-dev typescript tsx @types/node

@types/node deserves special mention: TypeScript itself knows built-in JavaScript APIs (Array, Promise, ...), but NOT Node.js-specific globals (process, require, filesystem modules) – @types/node provides exactly these missing type definitions.

package.json
{
  "name": "bibliotheks-app",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "start": "tsx src/index.ts",
    "build": "tsc",
    "typecheck": "tsc --noEmit"
  },
  "devDependencies": {
    "@types/node": "^22.0.0",
    "tsx": "^4.19.0",
    "typescript": "^5.6.0"
  }
}

"type": "module" enables native ES module syntax (import/export) instead of the older CommonJS system (require) – today's standard for new Node.js projects, which we'll use consistently throughout this tutorial.

  • npm start – runs src/index.ts DIRECTLY via tsx, for everyday development.
  • npm run build – compiles the ENTIRE project to real JavaScript (for a later production deployment, not a topic of the early chapters).
  • npm run typecheck – checks ONLY for type errors, without producing any file (--noEmit) – the fastest way to verify the ENTIRE project's type status.

Editor recommendation: VS Code

TypeScript was built by Microsoft, as was VS Code – the integration is correspondingly seamless: TypeScript errors appear LIVE in the editor, without manually invoking tsc, autocompletion works immediately with no extra configuration. Other editors (WebStorm, Neovim with LSP) work well too, but sometimes need additional plugins for the same level of comfort.

Tipp: Go ahead and create an empty src/ folder now – in the next chapter we'll fill it with the first index.ts file and set up the actual TypeScript configuration (tsconfig.json).