Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
birdflesh opened this issue Sep 19, 2023 · 3 comments

Comments

@birdflesh
Copy link

birdflesh commented Sep 19, 2023

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?:
@MateuszKikmunter
Copy link

MateuszKikmunter commented Dec 7, 2023

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

@Erhannis
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants