tsconfig-replace-paths icon indicating copy to clipboard operation
tsconfig-replace-paths copied to clipboard

ENOENT: no such file or directory, open 'C:\projectpath\@tsconfig\node16\tsconfig.json

Open neckaros opened this issue 2 years ago • 4 comments

When running i get an error with this module trying to get a tsconfig at an odd path. I tried putting absolute path for the --project to no avail

tsc -p tsconfig.json && tsconfig-replace-paths -v --project tsconfig.json

Using tsconfig: C:\_projectpath_\tsconfig.json
node:internal/fs/utils:348
    throw err;
    ^

Error: ENOENT: no such file or directory, open 'C:\_projectpath_\@tsconfig\node16\tsconfig.json'
    at Object.openSync (node:fs:599:3)
    at Object.readFileSync (node:fs:467:35)
    at loadConfig (C:\_projectpath_\node_modules\tsconfig-replace-paths\dist\commonjs\util.js:16:28)
    at loadConfig (C:\_projectpath_\node_modules\tsconfig-replace-paths\dist\commonjs\util.js:49:53)
    at Object.<anonymous> (C:\_projectpath_\node_modules\tsconfig-replace-paths\dist\commonjs\index.js:41:48)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: 'C:\\_projectpath_\\@tsconfig\\node16\\tsconfig.json'
}

Node.js v18.7.0

neckaros avatar May 17 '23 07:05 neckaros

Something with @tsconfig is throwing it off I'm guessing?

Your tsconfig.json should be at the root and not @tsconfig\node16\tsconfig.json since your script says tsc -p tsconfig.json && tsconfig-replace-paths -v --project tsconfig.json

jonkwheeler avatar May 17 '23 13:05 jonkwheeler

Yes it's definitely not in "@tsconfig\node16\tsconfig.json" I don't know where it gots those folders that does not exist

neckaros avatar May 17 '23 21:05 neckaros

That's really weird. Something in your project is telling it to use a tsconfig that does not exist.

What does tsc -p ./tsconfig.json do?

jonkwheeler avatar May 18 '23 12:05 jonkwheeler

It works well but i think i found the issue. I forgot that my tsconfig is extending and existing one (from my bootstrap):

{
  "extends": "@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
...

tsc and VSCode (when I ctrl+click on the path) successfully locate it but it's in fact under the node_modules directory: "...\node_modules@tsconfig\node16\tsconfig.json"

i think both VSCode and tsconfig also look in node_modules directory but not your code. (did a little search and found the commit: https://github.com/microsoft/TypeScript/issues/18865)

I changed path to:

{
  "extends": "./node_modules/@tsconfig/node16/tsconfig.json",
  "compilerOptions": {
    "target": "ES2020",  

and it's working

I'm not closing this issue myself letting you decide if you want to close or adapt to this specific case

And thanks for taking the time to help!

neckaros avatar May 19 '23 22:05 neckaros