尝试使用 dotnet 核心后端运行 spa 应用程序并在 mac OS 上的 Visual Studios 中运行反应前端时发生错误。 这似乎是一个 Visual Studios 错误
这是错误
Error: Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE.
这是csproj文件的相关部分
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
<Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
</Target>
这一行特别是抛出错误
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
当我打字时
node --version
我得到 v15.5.0
此外,当我在命令行中使用 dotnet run
运行该应用程序时,该应用程序运行得非常好。有谁知道如何解决这个问题?
答案 0 :(得分:0)
这个错误很可能是我最近将 Mac OS 升级到 Big Sur 11.1 引起的。我需要做的就是更新 VS 并修复此错误。