Ts-node: TSError: ⨯ Unable to compile TypeScript (v3.2.0)

Created on 10 Jul 2017  Â·  12Comments  Â·  Source: TypeStrong/ts-node

ts-node Version: 3.2.0

Description:
I updated my npm packages today (including ts-node) and then attempted to re-run my unit tests (via Karma/Jasmine). Unfortunately, I'm unable to share my original project with you, but while investigating this issue, I found #156, so I wanted to create a new issue to indicate that it seems to be a recurring problem.

Actual behavior:
I received the following error in the console.

09 07 2017 17:48:18.989:ERROR [config]: Invalid config file!
TSError: ⨯ Unable to compile TypeScript
Cannot find type definition file for 'jasmine'. (2688)
Cannot find type definition file for 'node'. (2688)
Cannot find type definition file for 'sinon'. (2688)
Cannot find type definition file for 'source-map'. (2688)
Cannot find type definition file for 'uglify-js'. (2688)
Cannot find type definition file for 'webpack'. (2688)
at getOutput (C:\xyznode_modules\ts-node\src\index.ts:312:15)
at C:\xyznode_modules\ts-node\src\index.ts:343:16
at Object.compile (C:\xyznode_modules\ts-node\src\index.ts:459:19)
at Module.m._compile (C:\xyznode_modules\ts-node\src\index.ts:395:43)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\xyznode_modules\ts
-node\src\index.ts:398:12)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.parseConfig (C:\xyznode_modules\karma\lib\config.js:363:22)
at new Server (C:\xyznode_modules\karma\lib\server.js:56:20)
at Object.exports.run (C:\xyznode_modules\karma\lib\cli.js:280:7)
at Object. (C:\xyznode_modules\karma\bin\karma:3:23)
at Module._compile (module.js:570:32)

Expected behavior:
I would expect that the code correctly compile and run my tests.

Additional information:
Version 3.2.0 is the latest version of ts-node available on NPM and the one currently installed when I ran into this issue. I resolved this problem by rolling back to [email protected]. I didn't make any other changes to the code, to configuration files or to the installed versions of other packages, but it now successfully builds without error and runs my tests.

needs more info research

All 12 comments

Feel free to create a reproduction and I'll review it. Otherwise you can review the changes here: https://github.com/TypeStrong/ts-node/commit/3f0d97520ccd7574566e5970cc511937f06599af#diff-f41e9d04a45c83f3b6f6e630f10117feL542. That's the only code that changed how paths are read, but if anything I would have expected an improvement - I'm literally using the ts.sys methods now.

I'll see if I can't identify a smaller repro to share and get back to you.

Same problem here, only that downgrading ts-node does not help. This bug only occurs after an update to yarn 0.27.5. With yarn 0.24.6 it's working fine.

I'm also running into this with karma tests?

Started to occur after upgrading to typescript 2.4.1 but was able to fix it by removing ts-node...

@blakeembrey

this can be reproduced when you use the ts-node console.

$ npm install -g ts-node
/usr/local/bin/ts-node -> /usr/local/lib/node_modules/ts-node/dist/bin.js
/usr/local/bin/_ts-node -> /usr/local/lib/node_modules/ts-node/dist/_bin.js
/usr/local/lib
└─┬ [email protected] 
  └─┬ [email protected]
    └─┬ [email protected]
      └─┬ [email protected]
        └── [email protected] 

$ npm install typescript -g
/usr/local/bin/tsc -> /usr/local/lib/node_modules/typescript/bin/tsc
/usr/local/bin/tsserver -> /usr/local/lib/node_modules/typescript/bin/tsserver
/usr/local/lib
└── [email protected] 

Now start the ts-node console. and print hello!

$ ts-node 
> console.log('hello');
⨯ Unable to compile TypeScript
[eval].ts: Cannot find name 'exports'. (2304)
[eval].ts (0,11): Cannot find name 'module'. (2304)
>
(To exit, press ^C again or type .exit)
> 


@rajgopalv That issue is unrelated, but logged - see https://github.com/TypeStrong/ts-node/issues/351.

Experiencing the same issue with:
ts-node v3.3.0
node v8.4.0
typescript v2.4.2

Reproduction

~ ts-node
> const x = 5;
Thrown: ⨯ Unable to compile TypeScript
[eval].ts: Cannot find name 'exports'. (2304)
[eval].ts (0,11): Cannot find name 'module'. (2304)

Having the same issue as @iDaN5x

ts-node v3.3.0
node v8.5.0
typescript v2.5.2

@Olian04 @SamuelMarks @iDaN5x,

Assuming all of you were trying to run ts-node in REPL mode the problem can be worked around by installing @types/node in a working directory, such as ts-node-repl, and then npm install @types/node. And then use ts-node in that directory as @blakeembrey mentioned in issue 351. Apparently this will be fixed "properly" in ts-node release 4.0

Closing as it should be resolved since 4.0. Thanks @winksaville.

### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### __

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grissius picture grissius  Â·  3Comments

nehalist picture nehalist  Â·  3Comments

conordickinson picture conordickinson  Â·  4Comments

mattdell picture mattdell  Â·  4Comments

sodiumjoe picture sodiumjoe  Â·  4Comments