{"id":14987,"library":"tsx","title":"tsx: TypeScript Execute","description":"tsx (TypeScript Execute) is a command-line interface (CLI) tool that enhances Node.js by providing a seamless way to run TypeScript and ESM files directly, leveraging esbuild for fast transpilation. It allows developers to execute TypeScript without a separate compilation step. The current stable version is 4.21.0. The project is actively maintained with frequent minor releases and bug fixes, often occurring every few weeks.","status":"active","version":"4.21.0","language":"javascript","source_language":"en","source_url":"https://github.com/privatenumber/tsx","tags":["javascript","cli","runtime","node","cjs","commonjs","esm","typescript","typescript runner"],"install":[{"cmd":"npm install tsx","lang":"bash","label":"npm"},{"cmd":"yarn add tsx","lang":"bash","label":"yarn"},{"cmd":"pnpm add tsx","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"/* my-script.ts */\nfunction greet(name: string) {\n  console.log(`Hello, ${name}!`);\n}\n\ngreet('TypeScript');\n\n// To run this:\n// npx tsx my-script.ts","lang":"typescript","description":"Demonstrates how to run a TypeScript file directly using the `tsx` CLI without prior compilation."},"warnings":[{"fix":"Upgrade your Node.js runtime to version 18.0.0 or newer using a version manager like nvm or volta.","message":"tsx requires Node.js version 18.0.0 or higher. Running with an older version will result in an error.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Be aware that tsx manages TypeScript transpilation independently of Node.js's native --loader options.","message":"tsx overrides Node.js's native experimental TypeScript loader, meaning its behavior might differ from Node.js's built-in TypeScript execution.","severity":"gotcha","affected_versions":">=4.20.4"},{"fix":"Use a separate type checker (e.g., tsc --noEmit) in your development workflow or CI/CD pipeline for type validation.","message":"tsx uses esbuild for transpilation, which performs no type checking during execution. Type errors in your code will not prevent a script from running.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Simplify tsconfig.json if possible, or verify specific compilerOptions behavior. Ensure baseUrl is correctly configured if using path aliases.","message":"While tsx generally handles tsconfig.json `paths` and `baseUrl`, complex tsconfig configurations or specific `compilerOptions` might not be fully supported by its underlying esbuild transpiler.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-18T00:00:00.000Z","next_check":"2026-07-17T00:00:00.000Z","problems":[{"fix":"Upgrade Node.js to version 18.0.0 or newer using a version manager like nvm or volta.","cause":"The installed Node.js version is below the minimum requirement specified in the package's engines field.","error":"Error: The tsx runtime requires Node.js version 18 or higher."},{"fix":"Install tsx globally via `npm install -g tsx` or execute it using `npx tsx <your-script.ts>`.","cause":"The tsx CLI executable is not installed globally or is not accessible in your system's PATH.","error":"tsx: command not found"},{"fix":"Ensure your `baseUrl` and `paths` are correctly defined in `tsconfig.json`. tsx generally has good path alias support; verify project structure and import paths.","cause":"Path aliases defined in tsconfig.json might not be resolved correctly by tsx in some setups, or there's a misconfiguration in module resolution.","error":"Cannot find module 'some-alias' from '...' or similar module resolution errors."},{"fix":"Convert `require` statements to `import` statements, or ensure the file is explicitly treated as CommonJS (e.g., by using a `.cjs` extension or setting `type: \"commonjs\"` in the nearest `package.json`).","cause":"Attempting to use the CommonJS `require` function within a file that Node.js (and tsx) treats as an ES module.","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm"}