Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't start a REPL #2039

Open
skrat opened this issue Jul 21, 2023 · 1 comment
Open

Can't start a REPL #2039

skrat opened this issue Jul 21, 2023 · 1 comment

Comments

@skrat
Copy link

skrat commented Jul 21, 2023

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
@gfx
Copy link
Contributor

gfx commented Nov 19, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants