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
6
votes
3 answers

Not able to run typescript node.js app with ts-node with pm2

I have created a basic node app with typescript top of it. I am using ts-node to do so and it's working totally fine with nodemon. But I need to move it to the server now I am stuck. PM2 is showing error all the time. I have gone through GitHub and…
Shailesh Jha
  • 1,122
  • 1
  • 8
  • 9
6
votes
1 answer

How do I make Typescript pick up a declaration file?

My file src/auth/ManagementAPI.ts uses Auth0. I need to use my own declaration file and have created src/@types/auth0.d.ts. However, when I run ts-node, I'm getting this error: TSError: ⨯ Unable to compile TypeScript: auth/ManagementAPI.ts(1,69):…
Dancrumb
  • 26,597
  • 10
  • 74
  • 130
6
votes
2 answers

Automatically compile TypeScript files on file save

I'm looking to move a vanilla node.js project to TypeScript and I'm curious about how to restart my server with the latest changes without needing to run tsc from the command line each time I make a change. I see from this answer two options:…
johnnyodonnell
  • 1,838
  • 3
  • 16
  • 34
6
votes
0 answers

How do I get WebStorm using ts-node with node --inspect to hit the proper line?

I'm using TypeScript to power an Express application. I have nodemon instantiating node with the --inspect option. I CAN connect a debug session, and hit a breakpoint in WebStorm. I cannot get it to hit the proper line. Here's my…
Jack Murphy
  • 2,952
  • 1
  • 30
  • 49
5
votes
1 answer

How to use Triple-Slash Directives in ts-node

I am just studying about typescript and its module system. Meanwhile, I found out Triple-Slash Deirectives. I just thought it is alternative expression of import / export. but It don't work as a thought. In below codes, I want to use namespace…
SpookyJelly
  • 105
  • 10
5
votes
0 answers

ts-node not able to find modules

I am facing issues when running a *.ts file using ts-node. The directory structure of my project looks like this. -- project dir -- src -- services -- module1 -- file1.ts (classA) -- file2.ts (classB) …
Jay Bhatt
  • 5,601
  • 5
  • 40
  • 62
5
votes
0 answers

How to use normal imports and top-level await at the same time?

I want to use imports (import x from y) and top-level awaits at the same time with ts-node. However if I change my tsconfig.compilerOptions.module to es2017 or higher as required by top-level awaits I get: SyntaxError: Cannot use import statement…
leonheess
  • 16,068
  • 14
  • 77
  • 112
5
votes
0 answers

Unknown file extension error after adding 'type: module' to package.json

I'm working in TypeScript, using modern import statements. Running nodemon (which then uses ts-node) this obviously results in SyntaxError: Cannot use import statement outside a module. Fair enough, so I added "type": "module" to my package.json…
Timmiej93
  • 1,328
  • 1
  • 16
  • 35
5
votes
3 answers

using esm modules with ts-node

I successfully ran ts-node that transpiles to CommonJS modules. I used the official: docs I also wanted to use esm modules following the official esm docs, but was unfortunately unsuccessful. The error I keep getting is: CustomError: Cannot find…
sanjihan
  • 5,592
  • 11
  • 54
  • 119
5
votes
1 answer

Cannot run ts-node with .tsx files

I have created a React app with Typescript and JSX (creating .tsx files instead of .ts) which I am attempting to run in a docker container with hot reloads but with little success. I've tried using nodemon in conjunction with ts-node but keep…
mark_h
  • 5,233
  • 4
  • 36
  • 52
5
votes
2 answers

zsh: command not found: ts-node

ts-node appears to be installed, the package is visible users/user/node_modules/ts-node, but when entering ts-node in the command line or trying to run a command I receive the error "zsh: command not found: ts-node". installed via 'sudo npm install…
MJH
  • 51
  • 2
5
votes
0 answers

tsconfig causes [ERR_REQUIRE_ESM]: Must use import to load ES Module

I already know how to solve the error [ERR_REQUIRE_ESM]: Must use import to load ES Module but I noticed that it caused by setting paths to refer to node_modules in tsconfig.json and I don't know the exact reason. tsconfig.json { "compileOnSave":…
Sh eldeeb
  • 1,589
  • 3
  • 18
  • 41
5
votes
3 answers

"Unexpected token ." when using optional chaning "?." syntax when running mocha

I'm playing around with TS and encountered an error when trying to run a test for my code. I have a the following piece of code: return this._map.get(y)?.get(x) When I run the code for browser, everything works fine. When I run a test using mocha,…
Igor K.
  • 750
  • 9
  • 25
5
votes
1 answer

Vscode breakpoints for TypeScript Mocha tests

I have started developing a Node/ExpreeJS project in TypeScript. I should note that I am not running node directly. I am running node in a docker but I do not see any reason that this would be an issue. I am using vscode as my editor and I am trying…
Andrew Butler
  • 687
  • 1
  • 6
  • 12
5
votes
2 answers

internal/modules/cjs/loader.js:800 throw err

Executed yarn install in my project folder and got below error. internal/modules/cjs/loader.js:800 throw err; ^ Error: Cannot find module 'ts-node/register' Require stack: - internal/preload ?[90m at Function.Module._resolveFilename…
Himanshu Shekhar
  • 1,196
  • 1
  • 16
  • 35