#Problems with installing/using typescript

22 messages · Page 1 of 1 (latest)

barren bolt
#

Hey! I just downloaded typescript and everything looked fine, but when i tried to use it on VS Code this error happened ```PS C:\Users\JoséEduardo\Desktop\WildOrange\Aprendendo programação B)> tsc teste.ts
C:\Users\JoséEduardo\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:93
for (let i = startIndex ?? 0; i < array.length; i++) {
^

SyntaxError: Unexpected token ?
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\JoséEduardo\AppData\Roaming\npm\node_modules\typescript\bin\tsc:2:1)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)```

i don't know if i did something wrong while downloading it or executing it but here is the error that appeared for me. Could someone help me?

pseudo cipher
#

Do you have a tsconfig.json file at the root of that directory?

final relic
#

if you run tsc teste.ts (with an explicit filename) then tsconfig.json won't be used anyway

#

typically you'd set up a config file and specify what files to include there, then just run tsc without giving it a specific file to compile

barren bolt
barren bolt
#

if i try to see what version tsc is the same error occurs

C:\Users\JoséEduardo\AppData\Roaming\npm\node_modules\typescript\lib\tsc.js:93
  for (let i = startIndex ?? 0; i < array.length; i++) {
                           ^

SyntaxError: Unexpected token ?
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\JoséEduardo\AppData\Roaming\npm\node_modules\typescript\bin\tsc:2:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)```
final relic
#

oh wow, i didn't look closely at your stack trace. that error is coming from tsc itself!

#

how did you download/install typescript?

pseudo cipher
#

@barren bolt What does node --version return?

#

The ?? operator is Node 14+ (??= is Node 16, my bad)

barren bolt
pseudo cipher
#

That's prehistoric

#

Latest LTS is 20.11.0

#

Latest stable is 21.6.0

barren bolt
#

aight, im gonna update my node.js and see what happens 😄

pseudo cipher
#

The version you have was released on August 6 2019

#

Yeah, start with that 🙂

barren bolt
#

it worked!

#

thanks!