【发布时间】:2021-04-06 14:55:46
【问题描述】:
尝试使用 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 运行应用程序时,应用程序运行得非常好。有谁知道如何解决这个问题?
【问题讨论】:
标签: node.js visual-studio .net-core single-page-application