cevek / ttypescript

Over TypeScript tool to use custom transformers in the tsconfig.json
1.53k stars 56 forks source link

"TypeError: Cannot read property 'split' of undefined" when getting Typescript version numbers #143

Open ccmetz opened 1 year ago

ccmetz commented 1 year ago

I just started getting this error today when compiling my typescript project. It's really confusing because as far as I can tell, I've been using the same versions of these dependencies for awhile.

Relevant dependencies: ttypescript: 1.5.12 typescript: 4.3.4

/app/node_modules/ttypescript/lib/loadTypescript.js:29
cc_api  |     var _e = ts.versionMajorMinor.split('.'), major = _e[0], minor = _e[1];
cc_api  |                                   ^
cc_api  |
cc_api  | TypeError: Cannot read property 'split' of undefined
cc_api  |     at Object.loadTypeScript (/app/node_modules/ttypescript/lib/loadTypescript.js:29:35)
cc_api  |     at Object.<anonymous> (/app/node_modules/ttypescript/lib/tsc.js:8:27)
cc_api  |     at Module._compile (internal/modules/cjs/loader.js:1114:14)
cc_api  |     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
cc_api  |     at Module.load (internal/modules/cjs/loader.js:979:32)
cc_api  |     at Function.Module._load (internal/modules/cjs/loader.js:819:12)
cc_api  |     at Module.require (internal/modules/cjs/loader.js:1003:19)
cc_api  |     at require (internal/modules/cjs/helpers.js:107:18)
cc_api  |     at Object.<anonymous> (/app/node_modules/ttypescript/bin/tsc:2:1)
cc_api  |     at Module._compile (internal/modules/cjs/loader.js:1114:14)

Does anyone know of anything that changed lately that could've caused this to break?

samchon commented 1 year ago

Upgrade ts version to latest

Eoic commented 1 year ago

Upgrade ts version to latest

I have the same problem with the latest versions: typescript: 4.9.5 and ttypescript: 1.5.15.

ccmetz commented 1 year ago

@Eoic Double check that your build is using those versions in your package-lock.json file. I just updated to typescript 4.9.5 and ttypescript 1.5.15 and it seems to have fixed the issue for me

egriff38 commented 1 year ago

Seeing the issue as well, but only after upgrading my node version from 14.20.0 to 14.21.3. I think the security releases from February 16 may have screwed something up for ttypescript.

EDIT Verified that

  1. The build works without issue up to the point release before the security issue (v 14.21.2 for me)
  2. Following @ccmetz advice and updating to the latest typescript and ttypescript versions does in fact fix the issue.
ccmetz commented 1 year ago

@egriff38 That could definitely be it. I was using a base node:14 docker image and it looks like there was a commit just a few days ago to update from node 14.21.2 to 14.21.3. I started noticing the issue just yesterday.

DetachHead commented 1 year ago

anyone know the newest node version where this isn't broken? i tried on some old 18 and 19 releases but it seems to have been broken on those for a while.

ccmetz commented 1 year ago

@DetachHead According to @egriff38 's comment above, it appears to be node 14.21.2

DetachHead commented 1 year ago

It still works on node 15.4 as well

ccmetz commented 1 year ago

@DetachHead ah okay, there could be a range of node versions where it might be broken then. It broke for me once my node 14 docker image was updated to 14.21.3.