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

问题描述 投票:0回答:1

我已经在 Vite 中安装了 React TS,但是在

tsconfig.json
中显示错误。我不知道为什么,因为我什至还没有尝试更改已安装的代码。这是什么原因?

tsconfig.json

  1. 错误:指定 TypeScript 如何从给定的模块说明符查找文件。

查看更多: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.

  1. 错误:允许导入包含 TypeScript 文件扩展名。需要设置“--moduleResolution bundler”和“--noEmit”或“--emitDeclarationOnly”。

  2. 错误:启用导入 .json 文件

reactjs typescript vite tsconfig
1个回答
2
投票

尝试将 vs 代码中的打字稿版本更改为“使用工作区版本” like that

© www.soinside.com 2019 - 2024. All rights reserved.