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

ubuntu20.04配置typescript遇到的一个问题以及解决方法 #14

Open
SSK015 opened this issue Jul 13, 2023 · 0 comments
Open

ubuntu20.04配置typescript遇到的一个问题以及解决方法 #14

SSK015 opened this issue Jul 13, 2023 · 0 comments

Comments

@SSK015
Copy link
Owner

SSK015 commented Jul 13, 2023

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: {

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

No branches or pull requests

1 participant