Questions tagged [ts-node]

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.

References

487 questions
26
votes
8 answers

ts-node and mocha 'TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts"' error even with "ts-node/esm" loader and CommonJS modules

Before ask this question, I checked similar topics and tried typical solutions. I know what the frequent cause is "module": "ESXXXX" in TypeScript configuration. In my case, I have error TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension…
Takeshi Tokugawa YD
  • 670
  • 5
  • 40
  • 124
24
votes
4 answers

How to use lodash-es in typescript correctly?

I need to use lodash-es in my typescript project, but I can't configure it correctly, it always reports errors like SyntaxError: Unexpected identifier hello.ts import upperCase from 'lodash-es/upperCase' console.log('Hello ' +…
Freewind
  • 193,756
  • 157
  • 432
  • 708
23
votes
8 answers

NestJS startup unbelievably slow in development

My application in dev environment is annoyingly slow in it's startup phase. I've set some debug logging on various places to see what is taking up so much time, and found that my main.ts actually uses almost 9 minutes just to get my app.module…
Øystein Amundsen
  • 3,993
  • 8
  • 44
  • 63
22
votes
7 answers

Running a simple express app with ts-node-dev and get error: False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`

I am new to typescript and express. I am trying to run the simplest express app using ts-node-dev, but get the following error. > ./node_modules/.bin/ts-node-dev src/index.ts 16:07:40 [INFO] 16:07:42…
Hantong Liu
  • 555
  • 1
  • 3
  • 12
22
votes
5 answers

Unknown file extension ".ts" error appears when trying to run a ts-node script

I'm trying to run a script created in a regular folder with two .ts files. One with the script and one with helper functions to run it. I'm also importing more things such as axios or form-data. The thing is that when I try to run the script with…
Emiliano
  • 437
  • 1
  • 4
  • 14
20
votes
1 answer

How to be able to set up breakpoints correctly when using VS Code to debug a TypeScript app run using ts-node in a Docker container?

Our app is written in TypeScript and uses Docker, and to avoid round-tripping through .js files, we're running it with ts-node to load the .ts files directly. Unfortunately this seems to make VSCode confused as to where valid lines of code are for…
millimoose
  • 39,073
  • 9
  • 82
  • 134
18
votes
2 answers

Error cause property not recognized in TypeScript

I stumbled upon the possibility to add a cause to the Error constructor in javascript. But when I try to use this feature my app does not start as it does not know this "new" constructor arg. > tsc && node…
andymel
  • 4,538
  • 2
  • 23
  • 35
18
votes
2 answers

How to reconcile monorepo with multiple tsconfig.json each having its own paths?

We have a codebase setup like so: -A --utils ---index.ts --index.ts --tsconfig.json -B --utils ---index.ts --index.ts --tsconfig.json -tsconfig.json Our root tsconfig.json contains the following: "paths": { "A/*": ["A/*"], "B/*":…
Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
17
votes
2 answers

How to use ts-node ESM with node modules?

Note: I am aware that the following question is about an experimental feature. I have created a clone on the ts-node discussion forum. However, I believe StackOverflow has a wider exposure and would lead to a solution in less time. I am trying to…
Kaustubh Badrike
  • 495
  • 1
  • 4
  • 18
15
votes
2 answers

TypeORM getRepository.find() does not include Foreign Key Fields

I am trying to fetch all the columns included on my entity, but I only able to fetch the columns that does not have any relationship from the other entity. I use this block of codes to fetch the all the rows to this repository. private…
Rich
  • 3,928
  • 4
  • 37
  • 66
15
votes
9 answers

Heroku deploy using ts-node

I am trying to deploy a sample of the Angular Universal Starter in Heroku. The task npm start fails because it does not recognize ts-node. Is there a way to make deployment on Heroku work using ts-node?
Joao Garin
  • 573
  • 1
  • 5
  • 16
14
votes
3 answers

ts-node with tsconfig-paths won't work when using esm

I couldn't figure out why ts-node isn't resolving the alias when esm is enabled I made a tiny project trying to isolate the issue as much as possible package.json { "type": "module" } tsconfig.json { "compilerOptions": { "module": "es2020",…
unloco
  • 6,928
  • 2
  • 47
  • 58
14
votes
3 answers

ts-node cannot find module typescript

I'm deploying a dockerized typescript app on AWS. When I run the app container I get a ts-node error Error: Cannot find module 'typescript' which is not clear to me because typescript is defined as a devDependency. These are my package.json…
Marcello Bardus
  • 365
  • 2
  • 4
  • 13
14
votes
1 answer

ts-node pass options to node

Is there a way to pass options to node when invoking ts-node? I am trying to use an experimental feature in node and it would be swell if it would work with ts-node. This is currently what I am doing: ts-node ./src/utils/repl.ts --…
unflores
  • 1,764
  • 2
  • 15
  • 35
14
votes
3 answers

TypeError: Object prototype may only be an Object or null: undefined

Below if I import Entity I get the posts's subject error (TypeError: Object prototype may only be an Object or null: undefined), but if I replace the import with the actual Entity declaration the code runs fine. Stackblitz demo here. This is…
Ole
  • 41,793
  • 59
  • 191
  • 359
1
2
3
32 33