I've finally managed to solve it!
My command on the terminal:
yarn tsc main.ts && nodejs main.js
My error message:
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.
What I did to solve it, was referencing the tsconfig.json file.
My tsconfig.json file was like this:
{
"compilerOptions": {
"target": "ESNext",
"lib": [
"ES2015",
"DOM"
]
}
}
And my terminal command is like this:
yarn tsc -p ./tsconfig.json && nodejs main.js
If I want to run other .ts file I simply do:
yarn tsc -p ./tsconfig.json && nodejs file_name.js