为什么我从 Vite 安装 React TS 时 tsconfig 出现错误?

Bah*_*din 12 typescript reactjs tsconfig vite

我已经在 Vite 中安装了 React TS,但它在tsconfig.json. 我不明白为什么,因为我什至还没有尝试更改已安装的代码。是什么原因?

[tsconfig.json ](https://i.stack.imgur.com/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
Run Code Online (Sandbox Code Playgroud)

小智 36

尝试将 VS Code 中的打字稿版本更改为“使用工作区版本”, 如下所示

  • 要获得此选项,请单击 VSCode 底部面板上“Typescript React”附近的大括号,单击“选择版本”,屏幕顶部将弹出使用工作区版本的选项 (7认同)