To run locally..
ts-node needs to be installed. You'll also need to install express, react, and react-dom.
- Make
tsConfig.json
a sibling toserver.tsx
- run like so
$ NODE_PORT=8888 ts-node server.tsx
- open http://localhost:8888/ in a browser.
"module": "commonjs"
import
statements need to be compiled to require
statements so that Node <=12 can understand them. See ts-node docs re: ESM support.
"jsx": "react"
We're running directly in Node after the TS compilation, so we need JS instead of JSX. See TS documentation re: jsx.
"esModuleInterop": true
TS compiler will error with this if it's not included: "This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag."