Short for TypeScript Node. Built to execute TypeScript for Node.js. You might also include TypeScript and/or Node.js - tags if you use this tag.
Questions tagged [ts-node]
487 questions
7
votes
2 answers
Unable to attach a debugger while running jest tests
I'm unable to attach VS Code debugger while running jest tests. I tried configuring launch.json file with different alternatives I found, but they always fail with the following error message, complaining about a file in node_modules…

roguib
- 141
- 6
7
votes
0 answers
Why is typeRoots not recommended for specifying the location of d.ts files?
In the following SO comment, which has 19 upvotes, the user says the following with regards to Typescript declaration files and the use of typeRoots:
@Tom It looks for .d.ts files in the same places that it will look for
normal .ts files: as…

ptk
- 6,835
- 14
- 45
- 91
7
votes
1 answer
ts-node can't find my type definition files
When I run ts-node node_modules/jasmine/bin/jasmine I get these errors:
tsc/globals.ts:7:12 - error TS2304: Cannot find name 'SugarcubeState'.
7 State: SugarcubeState;
~~~~~~~~~~~~~~
Here is that global file:
/* eslint-disable…

Daniel Kaplan
- 62,768
- 50
- 234
- 356
7
votes
3 answers
invoke a child process via fork() when using ts-node
I have a typescript project and rather than using tsc first, I'm just running via ts-node directly.
In my code I need to create a child process with fork().
If I run code like child_process.fork('ChildProcess.ts') and ChildProcess.ts contains some…

lostdorje
- 6,150
- 9
- 44
- 86
7
votes
1 answer
Trying to use vue with ts-node
I came to a point where I would gladly import a .vue file in my server-side code.
Deeply, I don't really use the *.vue file exports yet but some code is common for client-side and server-side and refer these files.
I am using ts-node now for…

eddow
- 400
- 1
- 3
- 10
6
votes
0 answers
ts-node can't use dynamic imports or import statements while in repl or eval in the cli
I have been trying to run eval or import esm module from the repl and I just can't make it work. I have tried a few things I found on the internet.
ex: Is it possible to import a Typescript into a running instance of ts-node REPL?
Not sure I am…

Ricardo Silva
- 1,221
- 9
- 19
6
votes
0 answers
using tsconfig-paths with es modules
I have a typescript project that uses commonjs modules, I use ts-node to run it, and tsconfig-paths to resolve tsconfig.compilerOptions.paths at runtime.
now I want my project to migrate to use es modules, so I made some changes:
add type: module…

Sh eldeeb
- 1,589
- 3
- 18
- 41
6
votes
3 answers
NextJS: Run a Typescript script on the server
I have a NextJS/Typescript project where I want to add a CLI script which should process some files on the server.
Unfortunately I don't manage to run the script.
Example script src/cli.ts:
console.log("Hello world");
// Process files
I tried to…

Sonson123
- 10,879
- 12
- 54
- 72
6
votes
2 answers
Can't run a TS node + ES app - either get `ERR_UNKNOWN_FILE_EXTENSION ` or `new ERR_MODULE_NOT_FOUND`
I'm trying to compile my code as ES code (using "type": "module" inside package.json and "module": "esnext" inside tsconfig.json).
I can't run it using any of the 3 approaches below:
ts-node src/server.ts results in:
TypeError…

ilmoi
- 1,994
- 2
- 21
- 45
6
votes
0 answers
Cannot compile a typscript file with ts-node in a nextjs application with ts.config {"module": "esnext"}
I want to understand why this code below doesn't compile when "module" is set to "esnext". Here is the config.
helpers/seeder.ts
import * as faker from "faker";
import { User } from "../interfaces/user";
let user: User = {
userName:…

nhasanli
- 93
- 2
6
votes
1 answer
TypeError [ERR_UNKNOWN_FILE_EXTENSION]:
This is the command i'm trying to run ./bitgo-express --port 3080 --env test --bind localhost and I'm receiving following error:
(node:367854) ExperimentalWarning: The ESM module loader is experimental.
internal/process/esm_loader.js:90
…
user13691227
6
votes
1 answer
Specify alternate tsconfig.json for VS Code / ts-node / ts-node-dev
I'm migrating my project from JavaScript to Typescript.
I want to have the default tsconfig.json to show stricter warnings in VS Code, but have an alternate tsconfig.json with more lenient tsc compiler options to allow a successful build.
The…

Tom Hale
- 40,825
- 36
- 187
- 242
6
votes
3 answers
throw new TypeError(`${relative(cwd, fileName)}: Emit skipped`)
Hello I have the following typescript code:
import { getConnection } from "typeorm";
import { GraphQLClient } from "graphql-request";
import got from "got";
import database from "./utils/database";
...
When I execute:
cross-env NODE_ENV=development…

Tlaloc-ES
- 4,825
- 7
- 38
- 84
6
votes
4 answers
mocha and ts-node UnhandledPromiseRejectionWarning:TypeError: Cannot convert undefined or null to object
I am trying to setup ts-node with mocha however the test script always fails.
I have tried
mocha --require ts-node/register --extensions ts,tsx --watch --watch-files src 'src/**/*.spec.{ts,tsx}'
and
mocha --require ts-node/register…

Moamen Mohamed
- 325
- 2
- 12
6
votes
1 answer
Why is ts-node not compiling typescript file?
Why is ts-node not compiling and executing typescript file? It is used in terminal like "ts-node scriptfile" It just returns a blank line. What is wrong? Thanks for the help.

Pyjs
- 89
- 2
- 4