Byte Ebi's Logo

Byte Ebi 🍀

A Bit everyday A Byte every week

TypeScript Environment Setup

Setting up a TypeScript development environment

Ray

Set up a TypeScript development environment
Using NVM to install Node.js and npm, installing development tools.

NVM & NPM

Installing and Updating

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

or

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash

After installation, use the command below to check the npm version:

npm -v

Development Environment

typescript

Compiles .ts files into .js.

nodemon

Monitors all files in the directory where the command is executed and automatically restarts when a file changes.

ts-node

Executes TypeScript files directly.

npx ts-node your-typescript-file.ts

Initializing the Project

First, navigate to the project directory!

npm init -y # Initialize the project
npm install -D typescript nodemon ts-node # Install development tools

Modify the script/start section in package.json:

nodemon --exec ts-node index.ts

Initialize TypeScript configuration:

npx tsc --init

After running the command, a tsconfig.json file will be created.

Recent Posts

Categories

Tags