Why am I getting error in tsconfig when I install React TS from Vite?
Asked Answered
B

3

14

I have installed React TS in Vite, but it is showing me an error in tsconfig.json. I can't figure out why because I haven't even tried to change the installed code yet. What is the reason?

[tsconfig.json ](https://i.sstatic.net/obFT4.png)

> 1. error: Specify how TypeScript looks up a file from a given module specifier.
>
> See more: [https://www.typescriptlang.org/tsconfig#moduleResolution](https://www.typescriptlang.org/tsconfig#moduleResolution)
>
> vscode-file://vscode-app/c:/Users/User/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html
>
> Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy.
>
> 2. error: Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.
>
> 3. error: Enable importing .json files
Burning answered 20/4, 2023 at 13:4 Comment(0)
O
43

Try changing the typescript version in your vs code to "Use workspace version" like that

Osbourne answered 20/4, 2023 at 14:23 Comment(5)
But I don't have the "workspace version"Burning
Run "npm install" before thatOsbourne
You are correct, this fix it for meAran
How will I get this optionAardvark
to get this option, click on the curly braces near Typescript React on the bottom panel of VSCode, click Select Version and the option to use the workspace version will pop up on the top of your screenConnive
S
2

Adding the settings.json fix, which is in effect the same as the the top fix

This can be resolved by adding the following to your settings.json inside of your .vscode folder

{
  "typescript.tsdk": "node_modules/typescript/lib"
}
Sulla answered 15/12, 2023 at 13:54 Comment(0)
P
0

Try the node.js version under the version 18. It will avoid the error.

PS C:\Users\gowsh\Desktop\Weather Web App> node --version
v18.12.0
PS C:\Users\gowsh\Desktop\Weather Web App> npm create vite@latest
√ Project name: ... Weather App
√ Package name: ... weather-app
√ Select a framework: » React
√ Select a variant: » TypeScript
Punchboard answered 9/4 at 6:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.