NISHIO Hirokazu[Translate]
ts-node
TypeScriptnode.jsで動かす
$ ts-node src/foo.ts
:
import { Foo } from "./Bar"; ^ SyntaxError: Unexpected token {
$ node -v
v11.14.0

$ node -v
v13.9.0
:
(node:39469) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. import { Foo } from "./Bar"; ^^^^^^ SyntaxError: Cannot use import statement outside a module

tsconfig.json
diff
- "module": "esnext", + "module": "commonjs",
これで動くようになったのだが、umdとかの方が良いのだろうか?

"Engineer's way of creating knowledge" the English version of my book is now available on [Engineer's way of creating knowledge]

(C)NISHIO Hirokazu / Converted from [Scrapbox] at [Edit]