Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The generate option does not work with a fresh project of Vite with React #552

Closed
TheYarin opened this issue Mar 12, 2023 · 6 comments
Closed
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@TheYarin
Copy link

TheYarin commented Mar 12, 2023

Bug Report

I created an online demo here: https://stackblitz.com/edit/vitejs-vite-if2xwg?file=tsconfig.json

The only thing I added to the newly created project is the src/typia-templates folder.

Running the following command: npx typia generate --input src/typia-templates --output src/typia-generated --project tsconfig.json
produces the following error:

----------------------------------------
 Typia Generate Wizard
----------------------------------------
Error: Debug Failure. Unexpected moduleResolution: Node
    at Object.resolveModuleName (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:44046:37)
    at loader_1 (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:119377:117)
    at loadWithModeAwareCache (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:118997:46)
    at actualResolveModuleNamesWorker (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:119378:149)
    at resolveModuleNamesWorker (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:119667:26)
    at resolveModuleNamesReusingOldState (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:119765:24)
    at processImportedModules (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:121296:35)
    at findSourceFileWorker (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:121076:17)
    at findSourceFile (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:120922:26)
    at eval (file:///home/projects/vitejs-vite-if2xwg/node_modules/typescript/lib/typescript.js:120871:85)
Error: spawn node EPERM

Code: EPERM

Now, I did some digging and it looks like the problem is fixed when I open tsconfig.json and replace "moduleResolution": "Node", with "moduleResolution": 2,. Looks like typescript doesn't like receiving the normal value from tsconfig.json, it wants the enum representation instead.

I was able to bypass the issue by creating typia.tsconfig.json with the following content:

{
  "extends": "./tsconfig.json",
  "compilerOptions": { "moduleResolution": 2 }
}

(Bypass found thanks to this issue and this issue

@samchon samchon self-assigned this Mar 14, 2023
@samchon samchon added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Mar 14, 2023
@kongweiying2
Copy link

I'm getting this issue too, but with Next.js + React

@kongweiying2
Copy link

kongweiying2 commented Mar 20, 2023

@TheYarin

How do you get this bypass working? Is it just by creating a typia.config.json?

@samchon
Copy link
Owner

samchon commented Mar 20, 2023

Can someone summarize this issue?

As my main job is not frontend development, it is hard for me to analyze this issue

It would best if send a README PR in the Setup section.

@TheYarin
Copy link
Author

TheYarin commented Mar 20, 2023

@kongweiying2 I bypassed the issue by also passing --project tsconfig.typia.json to the npx typia generate command.
(The file name (tsconfig.typia.json) is arbitrary :))

@TheYarin
Copy link
Author

@samchon If I understand correctly, the problem is that when calling typescript via its API with the moduleResolution compiler option, it requires a numeric (enum) value instead of the string value that is usually used in the tsconfig.json file. (That's just plain confusing)

To bypass the issue, I created a new tsconfig file that extends the original one with a numeric value for moduleResolution.
(I didn't want to modify the original tsconfig.json to avoid breaking anything)

@kongweiying2
Copy link

Thanks that works well!

@LorenzHenk LorenzHenk mentioned this issue Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants