Repository navigation
ts-node dos not recognize end of input; keeps printing "..." #2150
Copy link
Copy link
Open
Description
Search Terms
repl, newline, ...
Expected Behavior
Expression is evaluted in REPL after hitting "enter":
> 1
1
>
Actual Behavior
Nothing happens, ts-node behavies like it expects the input to continue:
> 1
...
...
...
If you input something that is not a valid expression, you get something else:
> a
<repl>.ts:4:1 - error TS2304: Cannot find name 'a'.
4 a
~
<repl>.ts:3:1694 - error TS1005: '=' expected.
3 declare import assert = require('assert');declare import async_hooks = require('async_hooks');declare import buffer = require('buffer');declare import child_process = require('child_process');declare import cluster = require('cluster');declare import constants = require('constants');declare import crypto = require('crypto');declare import dgram = require('dgram');declare import diagnostics_channel = require('diagnostics_channel');declare import dns = require('dns');declare import domain = require('domain');declare import events = require('events');declare import fs = require('fs');declare import http = require('http');declare import http2 = require('http2');declare import https = require('https');declare import inspector = require('inspector');declare import net = require('net');declare import os = require('os');declare import path = require('path');declare import perf_hooks = require('perf_hooks');declare import punycode = require('punycode');declare import querystring = require('querystring');declare import readline = require('readline');declare import repl = require('repl');declare import stream = require('stream');declare import string_decoder = require('string_decoder');declare import sys = require('sys');declare import timers = require('timers');declare import tls = require('tls');declare import trace_events = require('trace_events');declare import tty = require('tty');declare import url = require('url');declare import util = require('util');declare import v8 = require('v8');declare import vm = require('vm');declare import wasi = require('wasi');declare import worker_threads = require('worker_threads');declare import zlib = require('zlib');declare import node:sea = require('node:sea');declare import node:sqlite = require('node:sqlite');declare import node:test = require('node:test')
Steps to reproduce the problem
I don't know. This happens on my machine, I have not been able to find what triggers it.
I have cleaned absolutely everything node-related that I could find on my machine several times, including all the caches. It is still happening.
Minimal reproduction
Specifications
- ts-node version:
- node version:
- TypeScript version:
- tsconfig.json, if you're using one:
ts-node v10.9.2
node v23.7.0
compiler v5.7.3
- package.json:
-
- Operating system and version:
OSX 15.3.1:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
cclamb commentedon Mar 29, 2025
Same problem here.
Specific information to recreate:
ts-node v10.9.2 /usr/lib/node_modules/ts-node
node v23.9.0
compiler v5.8.2 /usr/lib/node_modules/typescript/lib/typescript.js
(no tsconfig when this occurs)
OS/Version:
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues"
PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/"
LOGO=archlinux-logo
i will spend some time on this as I am able and if fixed I'll submit a patch.
Hi-Angel commentedon Mar 31, 2025
Same problem just started. Worth noting that it's something that starts happening on its own. Just this morning
ts-nodewas working fine and now it indefinitely waits for more input, no matter what valid finished code you enter. The only way to make it stop waiting is to pass invalid code.Hi-Angel commentedon Apr 1, 2025
Dug into for a while, I am at loss.
I found that this "sea" thing from the
declare import node:sea = require('node:sea');snippet is part ofnode_modules/@types/node/process.d.tsfile.It seemsts-nodetries to parseprocess.d.tsfile, which then goes south. But sure it wasn't always like this, right? So I tried downgradingtypescript = 4.3.2and@types/node = 18.11.9, but it changed nothing.Hi-Angel commentedon Apr 1, 2025
WorkaroundSolutionEdit
node_modules/ts-node/dist/repl.js(e.g. on my Archlinux global installation it is/usr/lib/node_modules/ts-node/dist/repl.js), and change one line as follows (you basically just add a&& !name.includes(':') &&code):After you save it and run
ts-nodethe first command will give your exception (Idk why), but further commands will work as expected.Explanation:
Just as I wrote previous comment I found where code is being generated, this paragraph.
state.inputis text that goes before a code a user enters.I also found that problem seems to come down to colons being in the identifier name (as I suspected from the beginning and finally got to test it). If I replace whole algo with hardcoded string, the problem with indefinite wait disappears after I remove all colon-containing identifiers.
However, now any first input would give this exception:
Not sure where it's coming from. Tried commenting out the
state.input += 'export {};void 0;line, still get the error. I think it comes from the files likenode_modules/ts-node/dist/ts-transpile-module.d.ts(and there are similar ones) that only contain exactly theexport {};line. But I stopped digging here.As mentioned in "Workaround" section, the exception only occurs on the first input, so, well, at least
ts-nodestarts working. I don't plan to do further digging as I spent more time than I planned. Leaving that to any other motivated person 😊Hi-Angel commentedon Apr 1, 2025
Actually, nvm the exception, my "workaround" is the solution. I just found that the exception only appears with newer typescript, but with deps downgraded per my comment above the problem doesn't appear.
repl: filter out module names that contain colon