ts-node
ts-node copied to clipboard
Can't start a REPL
Just when I was thinking TS/node ecosystem isn't too bad, this happened. I had a sudden need for a REPL, as I am used to it from Python:
~/W/r/rwdom/domlib master• ↑2 [1] yarn run ts-node --files --esm -T
yarn run v1.22.19
$ /home/skrat/Workspace/xxx/yyy/node_modules/.bin/ts-node --files --esm -T
> import { Face } from 'src/rw/dom/model/document';
/home/skrat/Workspace/xxx/yyy/domlib/<repl>.ts:2
export {};
^^^^^^
Uncaught SyntaxError: Unexpected token 'export'
> Face
/home/skrat/Workspace/xxx/yyy/domlib/<repl>.ts:1
import { Face } from 'src/rw/dom/model/document';
^^^^^^
Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import
I feel like a tried a bunch of related CLI flags, various combinations of those, various forms of import etc. all failing on me. What is the problem?
Specifications
- ts-node version: v10.9.1
- node version: v18.15.0
- TypeScript version: v5.1.6
- tsconfig.json, if you're using one:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"composite": false,
"declaration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"jsx": "react",
"lib": ["es2020", "dom"],
"module": "ES2020",
"moduleResolution": "node",
"outDir": "build",
"rootDir": "src",
"skipLibCheck": true,
"sourceMap": true,
"strictBindCallApply": true,
"target": "ES2019",
"typeRoots": [
"../node_modules/@types"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
]
}
- package.json:
{}
- Operating system and version: Linux
duplicate
- https://github.com/TypeStrong/ts-node/issues/2005