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
174
votes
31 answers
'ts-node' is not recognized as an internal or external command, operable program or batch file
I'm getting error in my Vs Code terminal and command prompt that 'ts-node' is not recognized as an internal or external command, operable program or batch file. while i'm trying the start command in the terminal npm run dev and i have added my…

Mugesh
- 1,753
- 2
- 10
- 5
145
votes
6 answers
ts-node ignores d.ts files while tsc successfully compiles the project
Having compiled my TypeScript project successfully, I intended to run it in VS Code's debug mode using ts-node. Problem is, ts-node can't find d.ts files I created (while tsc has no problem with it).
Project structure is:
/
conf/
dist/
…

Forseti
- 2,587
- 6
- 21
- 32
112
votes
11 answers
Is there a way to use npm scripts to run tsc -watch && nodemon --watch?
I'm looking for a way to use npm scripts to run tsc --watch && nodemon --watch at the same time. I can run these commands independently, but when I want run both of them, only the first one is executed.
eg:
"scripts": {
"runDeb": "set…

Nicolas Dominguez
- 1,243
- 2
- 10
- 10
111
votes
14 answers
False expression: Non-string value passed to `ts.resolveTypeReferenceDirective` in typescript
When I try to run ts-node-dev./index.ts, I get the below error, I updated my typescript and ts-node-dev, ts-node but this error keeps on popping if I remove dependencies that have @types/XXXX(eg:@types/express) it is working fine.
False expression:…

Mohamed Anser Ali
- 1,269
- 2
- 8
- 13
94
votes
15 answers
Cannot find module that is defined in tsconfig `paths`
I am trying to setup aliases for my mock server. Whenever I try to compile ts files, it returns error that it couldn't find proper modules even though those are defined in tsconfig,json->paths
Folder structure:
├── server
│ └── src
│ …

Jamil Alisgenderov
- 1,448
- 2
- 12
- 23
83
votes
2 answers
What's the difference between tsc (TypeScript compiler) and ts-node?
I'm very confused about the difference between tsc and ts-node. I'm learning TypeScript and I usually transpile server .ts files with tsc command.
Now, I'm approaching nestjs framework, and I see that it uses ts-node.
So what's the difference…

gremo
- 47,186
- 75
- 257
- 421
61
votes
3 answers
deno vs ts-node : what's the difference
I'm working on a relative large typescript project, I'm using ts-node to run node testing and examples. As far as I understand, ts-node will compile ts files to js files and execute.
Recently I heard about deno, which is a typescript runtime. I…

jerry
- 1,196
- 2
- 9
- 21
46
votes
6 answers
Typescript paths not working in an Express project
I am trying to use TypeScript's paths functionality so that I don't need to use relative imports any more.
Here is my tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
…

Sriram R
- 2,109
- 3
- 23
- 40
37
votes
7 answers
Why does the node inspector not start when I am using nodemon and ts-node?
I have a simple node server written in typescript. My package.json is configured as:
"scripts": {
"build": "tsc",
"dev": "nodemon --watch src/**/* -e ts,json --exec ts-node ./src/server.ts",
"debug": "nodemon --verbose --watch src/**/* -e…
user60456
35
votes
4 answers
How to pass parameters to a script processed by ts-node
I just started ts-node utilizing. It is the a very convenient tool. Run time looks clear. But it does not work for CLI solutions. I can not pass arguments into a script compiled.
ts-node --preserve-symlinks src/cli.ts -- printer:A
It does not work.…

Victor Shelepen
- 1,966
- 2
- 16
- 41
34
votes
4 answers
ts-node execute typescript with module import and module defined
I try to initialize database base via typescript.
my ts is like:
import { User, UserRole } from '../entity/User';
import crypto from 'crypto';
import {dbManager, pwhash } from '..';
async function inituser()
{
const user = new User();
…

user504909
- 9,119
- 12
- 60
- 109
32
votes
4 answers
Ts-node : SyntaxError: Cannot use import statement outside a module
I was trying to use the top level in the project and saw that it was necessary to change the module from tscofnig to esnext or system, but for some reason my ts-node's error.
And I already put the type: module I tried to use the flag:…

Ming
- 1,349
- 4
- 13
- 36
31
votes
7 answers
error TS1259: Module '"./node_modules/@types/express/index"' can only be default-imported using the 'esModuleInterop' flag
I'm trying to import express into the project and in the middle of the development, it just stopped working, i've reseted configurations, etc. Can't make it work, can't import any modules.
npx tsc src/server.ts
src/server.ts:1:8 - error TS1259:…

Francisco Pena
- 456
- 1
- 4
- 11
31
votes
1 answer
Importing nodejs `fs` with typescript when executing with ts-node?
I'm trying to run the following code with ts-node.
import { writeFileSync, readFileSync } from 'fs';
However I get:
src/main/ts/create.ts (1,45): Cannot find module 'fs'. (2307)
What do I need to do in to allow typescript to import the fs module?

Ole
- 41,793
- 59
- 191
- 359
27
votes
4 answers
How to use ts-node regardless of errors?
I've got some trouble with ts-node when I develop.
I want to test something, so as you know, comment is my best friend.
But with ts-node I've got this error :
'foo' is declared but its value is never read
But I don't want to comment all my unused…

La Gregance
- 271
- 1
- 3
- 5