我在自己 Windows中的typescript项目中使用ts-node:
项目目录如下:
package.json
{
"name": "ts-test01",
"version": "1.0.0",
"description": "",
"main": "main.js",
"dependencies": {
"typescript": "^5.0.2",
"ts-node": "^10.9.1"
},
"scripts": {
"dev": "ts-node src/main.ts"
},
"keywords": [],
"author": "",
"license": "ISC"
}
src/main.ts
const LogAAA = (str:string = 'AAA') => {
console.log(str)
}
LogAAA()
当我运行时候:npm run dev
报错如下:
\typescript.js:139
for (let i = startIndex ?? 0; i < array.length; i++) {
^
SyntaxError: Unexpected token '?'
请问这个是什么问题呢?
node 版本低了