Итак, я хотел бы использовать доступную начиная с версии TypeScript 3.8 верхнего уровня, ожидающего в NodeJS приложении. Итак, следующий код TypeScript:
import { getDoctorsPage } from "./utils/axios.provider";
const page = await getDoctorsPage("047", "1", "1");
console.log(page);
компилируется в этот JavaScript код:
import { getDoctorsPage } from "./utils/axios.provider";
const page = await getDoctorsPage("047", "1", "1");
console.log(page);
//# sourceMappingURL=index.js.map
И когда я пытаюсь запустить его в WebStorm, я получаю следующую ошибку:
(node:95053) ExperimentalWarning: The ESM module loader is experimental.
file:///Users/anatoly/Documents/git/maccabi-parser/dist/index.js:2
const page = await getDoctorsPage("047", "1", "1");
^^^^^
SyntaxError: Unexpected reserved word
at Loader.moduleStrategy (internal/modules/esm/translators.js:81:18)
at async link (internal/modules/esm/module_job.js:37:21)
Последний NodeJS 0.13. * Поддерживает это? Спасибо.
Мой tsconfig.json
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"pretty": true,
"sourceMap": true,
"outDir": "dist",
"importHelpers": true,
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"rootDir": "src",
"noImplicitAny": false,
"strictNullChecks": false,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"baseUrl": "./",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
и пакет. json содержит "type": "module"