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
14
votes
1 answer
Should ts-node examine the baseUrl tsconfig.json property?
I'm using ts-node and in tsconfig.json I have "baseUrl": "./src". This way I can import a sibling in src without using ./. However ts-node does not seem to using the baseUrl property in resolving the sibling imports, so I get errors like this:
…

Ole
- 41,793
- 59
- 191
- 359
13
votes
1 answer
How to use TypeScript Declaration File with mocha tests?
I have a TypeScript project, where the test are written in TypeScript. I want to use mocha to directly test TS files. I'm using ts-node for that, as described in ts-node#mocha.
In the project I'm using a JS library which doesn't have TS type…

Robert Zaremba
- 8,081
- 7
- 47
- 78
13
votes
7 answers
Is there any option to compile and run a ts code faster using tsc or ts-node or anything else?
Currently we have client server application (for competitive coding purposes) where client hit compile and run and sends ts code to server where ts code is stored in a file and run locally with testcases on server and output is returned to client…

Manoj Singh
- 131
- 1
- 1
- 4
12
votes
1 answer
Nestjs: import modules undefined, but methods and functions from modules can be imported
I am using Nestjs with WebStorm & TS 4.2.3^latest.
The problem that I am facing is a bit strange. For example, some modules, like axios can be installed, imported, and used as usual. But some modules, especially Nodejs Core, like fs or path, can't…

AlexZeDim
- 3,520
- 2
- 28
- 64
12
votes
3 answers
Cannot get nodemon/ts-node-dev working on dockerized mean stack
Brand new to the Mean Stack but have managed to get one set up in a dockerized environment by following various tutorials. I mainly used the one explained at…

John Cogan
- 1,034
- 4
- 16
- 39
12
votes
2 answers
TS-Node: Could not find sourceFile
My project has been using ts-node to run a mix of JavaScript and TypeScript. Recently it stopped working, without an obvious reason. At the most simple level, here is how it's run and the error it produces:
$ TS_NODE_PROJECT=./tsconfig.json…

Jonah
- 9,991
- 5
- 45
- 79
11
votes
5 answers
ts-node-dev not restarting when changes made
Here are my files :
package.json :
"scripts": {
"generate-interfaces": "ts-node src/cli/generate-interfaces.ts",
"dist": "npm run generate-interfaces && rm -rf dist && tsc && cp -r static/ dist/ && cp -r resource/ dist/",
"prestart": "npm run…

Himanshu Teotia
- 2,126
- 1
- 27
- 38
11
votes
1 answer
Profiling of a TypeScript Node.js application
I am looking for a tool to make the profiling of a TypeScript Node.js application, and this without modifying the whole code source.
I mean by profiling: launching the application using some specific tool, which outputs the result like this:
Method …

abderrahim_05
- 445
- 1
- 4
- 21
11
votes
2 answers
How to use a TypeScript method decorator and retain normal `this` scope
PLEASE NOTE: This issue was because of the use of GraphQL resolvers in running my decorated method. It meant that the scope of this was undefined. However, the basics of the question are useful for anyone hitting a problem with decorators.
This is…

jamesmhaley
- 44,484
- 11
- 36
- 49
11
votes
1 answer
Register Node Module Manually
Question:
I have a project in TypeScript that uses several APIs I don't have access to on my computer (they exist on the web). The code will compile fine locally since I have all the APIs in foo.d.ts files, and so the system knows they exist…

Jason
- 13,563
- 15
- 74
- 125
11
votes
1 answer
TypeScript ES dynamic `import()`
While using the new TypeScript feature, so called ES Dynamic Imports, I am not able to run the code of my isomorphic app on the server side using ts-node.
It seems like the error does not occur when using the webpack module loader which transpiles…

roomcayz
- 2,334
- 4
- 17
- 26
10
votes
2 answers
Cannot find module 'tsconfig-paths/register'
I'm trying to run a typescript script with ts-node in CLI, which means I don't have a package.json.
Here's the command I'm trying to run:
npx -p typescript@latest -p ts-node@latest -p @types/node@latest ts-node -T --project…

Michael Khaliavski
- 101
- 1
- 1
- 5
10
votes
2 answers
Typescript: import express unexpected idenfitier with ts-node-dev
I am starting a new project with Typescript and i would like to make the node server with typescript using express. I've been following a tutorial about how to run a Typescript file without having to compile files in this link:…

Oscar Reyes
- 4,223
- 8
- 41
- 75
9
votes
2 answers
TypeScript cannot find module with non-relative path 'src/xxx'
I had meet the problem that resolve non-relative moduels in typescript. And try baseUrl, paths and so on, but it not works....
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"baseUrl": ".",
"esModuleInterop": true,
"module":…

junlin
- 1,835
- 2
- 25
- 38
9
votes
2 answers
Cannot find Typescript module even though tsc successfully manages to resolve it
I have a Node.js project written in Typescript which is expected to run as a CLI, and am having trouble to import a module located out of the node_modules directory using an absolute path (relative paths work fine). It might be important to mention…

edu_
- 850
- 2
- 8
- 16