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
0
votes
1 answer
Setup Konva with Jest
I'm trying to setup Jest with Konva, but getting this error:
TypeError: Cannot read property 'Stage' of undefined
88 | }
89 |
> 90 | const stage = new Konva.Stage({
I have imported Konva with import Konva from 'konva' in my TS file,…

Ramin Mousavi
- 486
- 1
- 5
- 19
0
votes
1 answer
How to use typescript relative/absotule paths
Right now I need to write import { MyFn } from '../lib/myUtils'; instead of import { MyFn } from 'lib/myUtils';.
My structure is:
tsconfig.json
src -
index.ts
lib
- myUtils
....
I dont want to use any external library like…

nirebam368
- 245
- 4
- 11
0
votes
1 answer
Function wrapper returning function instead of actual object
I'm trying to create a wrapper around an async function, when I call the function I always get a function instead of the object I want to get.
function wrap(fn: T){
return async function (...args) {
let result =…

Ben Rhouma Zied
- 2,473
- 3
- 19
- 29
0
votes
2 answers
node-ts shows "error TS2304: Cannot find name '__DEV__'"
I recently added __DEV__ to some TypeScript file in my NodeJS project. In VSCode, this is not marked as an error.
However, when I run the project, I immediately get the error
error TS2304: Cannot find name '__DEV__'.
I tried adding /* global…

Jonas Sourlier
- 13,684
- 16
- 77
- 148
0
votes
2 answers
mikro-orm CLI: Cannot find module 'ts-node'
I'm attempting to use the mikro-orm CLI but am getting a ts-node error:
$ npx mikro-orm debug
npx: installed 280 in 14.531s
(node:19228) UnhandledPromiseRejectionWarning: Error: Cannot find module 'ts-node'Require stack:
-…

NadA
- 1
- 3
0
votes
1 answer
TypeScript compiler doesn't recognize definition files
I've been unit-testing some code that depends on interfaces and classes I am unable to import, but can add to intellisense through d.ts files. Despite having the "include" property in my tsconfig mention those files, I get errors about how…

Tespy
- 971
- 2
- 9
- 18
0
votes
1 answer
ts-node throws unrelated strange error, but no error was thrown when using tsc
When i run ts-node, it throw me these error
src/api/role.ts:2:58 - error TS2774: This condition will always return true since the function is always defined. Did you mean to call it instead?
2 var __createBinding = (this && this.__createBinding) ||…

Tan Vee Han
- 337
- 4
- 12
0
votes
1 answer
ava + ts-node converting .spec.ts files into .ts
I am running ava with ts-node with the following config:
"ava": {
"files": [
"tests/**/*",
"!test/exclude-files-in-this-directory",
"!**/exclude-files-with-this-name.*"
],
"failFast": true,
…

A. L
- 11,695
- 23
- 85
- 163
0
votes
2 answers
Why Occured Property 'user' does not exist on type 'Request'
I am getting the following error when running ts-node.
I defined d.ts as follows to use "req.user" and applied tsconfig.json.
Path: src/@types/express/index.d.ts
import { User } from '../../model/user/user.interface';
declare global {
…

COLEAN
- 665
- 2
- 9
- 24
0
votes
1 answer
Debugging TypeScript Node.js Compilation Error
I am trying to setup a debugging environment on an 2019 project so I added the following script to my package.json
"dev:debug": "tsc-watch --onFirstSuccess \"node --inspect -r ts-node/register src/app.ts\"",
Running it would give me the…

Rami
- 328
- 1
- 13
0
votes
1 answer
ts-node-dev not printing ts errors
I use ts-node-dev for compile and run my node app.
ts-node-dev -r tsconfig-paths/register src/collectDayMatches.ts
But ts-node-dev printing just runtime errors (not ts errors).
if I use tsc for the build app, I get errors as…

Edgaras Karka
- 7,400
- 15
- 61
- 115
0
votes
1 answer
Unhandled promise rejection error when I using parsing
When I run the following code:
const { dashdash } = require('dashdash');
const options = ....; //it's long so I replace them with ... to let me publish the post.
async function upload_photo() {
const parser = dashdash.createParser({options:…
0
votes
1 answer
How do I run Jasmine in browser mode if my tests are written in Typescript?
I am using Jasmine to unit test some legacy code that will run in the browser. Here is how I execute my tests: ts-node node_modules/jasmine/bin/jasmine
Because this is legacy code, it's using globals (ie: window). How do I execute Jasmine and tell…

Daniel Kaplan
- 62,768
- 50
- 234
- 356
0
votes
1 answer
Nuxt Typescript with Custom Server Framework: TypeError: [Babel]
I have been struggling for hours to get Nuxt Typescript to work programmatically with a custom server framework (Typescript Node/Express) but can't.
My guess is that there is some loader or transpile configuration that can solve this but searching…

ndemasie
- 590
- 1
- 6
- 17
0
votes
1 answer
Import statement works incorrectly if directly compiled, but works okay after saving it on VS Code
I'm having a problem where a certain import fails to work when compiling directly, but works okay after saving the source on VS Code.
If I delete the node_modules/.cache folder and execute the command:
yarn serve
It compiles okay, but then the…

Haroldo_OK
- 6,612
- 3
- 43
- 80