ts-node: Unable to use REPL on Windows or OS X.
For some reason I can’t get the REPL to work at all. Same result in both OS X and Windows.
Reproduction steps:
$ npm i -g typescript ts-node
$ ts-node
> console.log('hi');
Unable to compile TypeScript
[eval].ts (0,1): Cannot find name 'exports'. (2304)
[eval].ts (0,11): Cannot find name 'module'. (2304)
Node versions tried: v8.1.0
, v7.10.0
, v5.12.0
Version of ts-node installed: v3.0.6 (latest)
Edit:
Tried installing different versions of ts-node. Looks like the REPL breaks in v3.0.5
but works in v3.0.4
and earlier.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 19 (8 by maintainers)
I see. I’ll try to get a fix in the next few days for this, I think it’s (relatively) easy to work around. I didn’t consider the case where someone wouldn’t have the types installed being an issue 😄
To make it work today, you probably need a
tsconfig.json
file and@types/node
installed locally (no-g
, TypeScript would be looking up the types relative to yourtsconfig.json
file).Still getting this error.
npm install -g @types/node
does not work. It must be installed locally.Global attempt (failed): 👎
Local attempt success 👍
I would think this bug should remain open. REPL shouldn’t require local install. And if it does, it should error out gracefully if the dependency isn’t there.
Just verified, you only need to
npm install @types/node
in your working directory to get started for now. Though you’ll probably want atsconfig.json
eventually for other configuration. I’ll update this issue when I have a fix to avoid needing the typings all together.