TypeStrong / ts-node

TypeScript execution and REPL for node.js
https://typestrong.org/ts-node
MIT License
12.75k stars 529 forks source link

Use ts-node command to compile .ts file is unsuccessful ,throwing an error as is below #2066

Open birdflesh opened 10 months ago

birdflesh commented 10 months ago

Search Terms

ts-node E:XXXXX\nodejs\node_modules\typescript\lib\typescript.js:139 for (let i = startIndex ?? 0; i < array.length; i++) { ^

SyntaxError: Unexpected token ? at new Script (vm.js:79:7) at createScript (vm.js:251:10) at Object.runInThisContext (vm.js:303:10) at Module._compile (internal/modules/cjs/loader.js:656:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10) at Module.load (internal/modules/cjs/loader.js:598:32) at tryModuleLoad (internal/modules/cjs/loader.js:537:12) at Function.Module._load (internal/modules/cjs/loader.js:529:3) at Module.require (internal/modules/cjs/loader.js:636:17) at require (internal/modules/cjs/helpers.js:20:18)

Expected Behavior

Actual Behavior

Steps to reproduce the problem

Minimal reproduction

Specifications

MateuszKikmunter commented 7 months ago

I'm having exactly the same issue as above, node 18.18.0, ts-node: ^10.9.1 and typescript: ^5.3.2.

Erhannis commented 5 months ago

I was getting that error when I ran ts-node, but I upgraded my nodejs (via https://github.com/nodesource/distributions ) and the problem seems to have gone away. I'm on Ubuntu 20.04.6. My new versions are: nodejs: v20.11.0 npm: 10.2.4 ts-node: v10.9.2

KostrebaDV commented 5 months ago

I have the same error

/api/node_modules/typescript/lib/typescript.js:139
    for (let i = startIndex ?? 0; i < array.length; i++) {

Node.js v18.17.1 "typescript": "^5.3.3" "ts-node": "^10.9.2" macOs Ventura 13.6