我按照本教程为 windows 项目创建了新的 react-native 。我在 VS Code 中工作,但是要运行该应用程序,我必须安装 Visual Studio Community,否则它在启动时给了我错误:
error Unable to find vswhere
在我使用本教程中的所有选项安装 Visual Studio 后,错误变为:
Failed to restore the NuGet packages: Error:
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error :
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
我尝试寻找解决方案,推荐的是这个。所以我检查了我的命令行。运行dotnet --list-sdks
后只有一个版本:
3.1.402 [C:\Program Files\dotnet\sdk]
global.json
我在我的项目中使用以下文本创建了文件:
{
"sdk": {
"version": "3.1.402"
}
}
但是在我运行npx react-native run-windows
命令后,出现以下错误:
Failed to restore the NuGet packages: Error:
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error :
Unable to locate the .NET Core SDK. Check that it is installed and that the version specified in
global.json (if any) matches the installed version.
C:\Users\Alyona\Documents\Programming\accounting_app\node_modules\react-native-
windows\Microsoft.ReactNative.Managed.CodeGen\Microsoft.ReactNative.Managed.CodeGen.csproj : error
MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.
A compatible installed .NET Core SDK for global.json version [3.1.402] from
[C:\Users\Alyona\Documents\Programming\accounting_app\global.json] was not found