TypeStrong/ts-node

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

birdflesh opened this issue · 3 comments

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

  • ts-node version: v10.9.1
  • node version: v10.12.0
  • TypeScript version:5.2.2
  • tsconfig.json, if you're using one:{
    "extends": "@tsconfig/node10/tsconfig.json"
    }
{}
  • package.json:
{}
  • Operating system and version: win 10
  • If Windows, are you using WSL or WSL2?:

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

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

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