LuuVinhLoc
Vietnamese / Ja / En  🧑‍💻 blog

Vietnamese / Ja / En  🧑‍💻 blog

Run TypeScript file globally 🌠 with ts-node

Photo by Fernando Cortizo on Unsplash

Run TypeScript file globally 🌠 with ts-node

LuuVinhLoc's photo
LuuVinhLoc
·Jun 3, 2022·

1 min read

Run Globally mean we can run ts-node command everywhere without package.json.

Globally install ts-node

pnpm install -g typescript ts-node tslib @types/node

# verify
ts-node -v
  • tslib is a runtime library for TypeScript that contains all of the TypeScript helper functions.
  • @types/node contains type definitions for Node.js.

Prepare a simple sample

Create a ts file:

touch test.ts

Write a simple sample:

const teamName: string = '🦆🦆🦆';

console.log('🌊', teamName);

Run ts file everywhere

ts-node test.ts

Expected output is "🌊 🦆🦆🦆".

 
Share this