You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xyw@ubuntu:~/Documents/Code/Learning-typescript-from-scratch/src$ tsc hello.ts
/usr/local/lib/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. (/usr/local/lib/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)
https://ssk015.github.io/problemintypescriptconfig/
这几天心血来潮,想学typescript。先要配它的环境,在我的ubuntu20.04虚拟机上配环境。用apt-get工具分别以-g命令下载nodejs和npm之后,用tsc编译.ts文件时出现以下报错:
xyw@ubuntu:~/Documents/Code/Learning-typescript-from-scratch/src$ tsc hello.ts
/usr/local/lib/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. (/usr/local/lib/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)
尝试用npm重新安装typescript,出现以下报错:
root@ubuntu:/home/xyw/Documents/Code# npm install -g typescript
[..................] / rollbackFailedOptional: verb npm-session 072b7b0747965df0
[..................] / rollbackFailedOptional: verb npm-session 072b7b0747965df0
/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/bin/tsserver -> /usr/local/lib/node_modules/typescript/bin/tsserver
npm WARN notsup Unsupported engine for [email protected]: wanted: {
The text was updated successfully, but these errors were encountered: