Наконец-то мне удалось это решить!
Моя команда на терминале:
yarn tsc main.ts && nodejs main.js
Мое сообщение об ошибке:
main.ts:1:16 - error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.
1 async function main() {
~~~~
Found 2 errors.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Чтобы решить эту проблему, я сослался на файл tsconfig.json.
Мой файл tsconfig.json выглядел так:
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"ES2015",
"DOM"
]
}
}
И моя команда терминала такая:
yarn tsc -p ./tsconfig.json && nodejs main.js
Если я хочу запустить другой файл .ts, я просто делаю:
yarn tsc -p ./tsconfig.json && nodejs file_name.js
{ "compilerOptions": { "module": "commonjs", "target": "es5", "noImplicitAny": false, "sourceMap": false } }это мой tsconfig.json Как мне отредактировать?