run ts file without compiling All In One
run ts file without compiling All In One
$ npx ts-node ./app.ts
ts-node
$ yarn add -D ts-node
$ yarn add -D typescript
# Depending on the configuration, you may also need these
$ yarn add -D tslib
$ yarn add -D @types/node
https://www.npmjs.com/package/ts-node
https://github.com/TypeStrong/ts-node
https://typestrong.org/ts-node/
bugs
$ npx ts-node ./567\ permutation-in-string.ts
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/xgqfrms-mbp/Documents/GitHub/leetcode/js-solutions/567 permutation-in-string.ts
https://github.com/TypeStrong/ts-node/issues/1062
https://typestrong.org/ts-node/docs/module-type-overrides/
node & CJS
{
"type": "commonjs",
}
tsc & ESM
ts-node bug
{
"type": "module",
}
ESM vs CJS
tsconfig.json
{
"type": "module"
}
refs
https://stackoverflow.com/questions/33535879/how-to-run-typescript-files-from-command-line
https://www.educative.io/answers/how-to-execute-the-typescript-file-using-the-command-line
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16559320.html
未经授权禁止转载,违者必究!