justkey007 / tsc-alias

Replace alias paths with relative paths after typescript compilation
MIT License
876 stars 63 forks source link

File undefined not found error when loading tsconfig extends file [Yarn 2] #182

Open basal-luke opened 1 year ago

basal-luke commented 1 year ago

tsc-alias throws a File undefined not found exception when extending a tsconfig which has been installed via Yarn 2

Expected Behavior tsc-alias builds successfully when my tsconfig extends another tsconfig

Current Behavior tsc-alias throws a file not found error when when my tsconfig extends another tsconfig installed which is installed via Yarn 2 (plug n play)

Steps to reproduce

  1. Install a tsconfig package via Yarn 2 e.g https://www.npmjs.com/package/@tsconfig/recommended
  2. Extend this package in the project tsconfig "extends": "@tsconfig/recommended/tsconfig.json"
  3. Run tsc-alias

Example Repo https://github.com/basal-luke/tsc-alias-yarn-issue

basal-luke commented 1 year ago

Related: #176

bskinner commented 6 months ago

I ran into this same issue and did some digging into tsc-alias. From my understanding, it appears the resolveTsConfigExtendsPath in src/helpers/config.ts expects a node_modules folder to exist somewhere in the directory hierarchy when resolving the extends field (via the mylas package). When using Yarn versions >= 2, Yarn uses it's PnP API by default for resolving modules, and does not create a node_modules directory. I have not verified that this is the only location which may need changes.

Changing the value of the nodeLinker key to node-modules in my .yarnrc.yml and rerunning yarn to reinstall the dependencies fixed the issue (but does reintroduce the node_modules folder, which may be undesirable in some setups).

ChoSeoHwan commented 1 month ago

i have same issue