I need to build and run a .NET 5 project in Mac using Visual Studio for Mac or Jetbrains Rider.
In csproj
file of one of the projects in the solution, I have following Target:
<Target Name="SassBuild" BeforeTargets="Build" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Exec Command="npm i" />
<Exec Command="npm rebuild node-sass" />
<Exec Command="npm run gulp-sass" />
<Exec Command="npm run gulp-js" />
</Target>
When I run dotnet build
or dotnet msbuild
project builds just fine, however building it in VS/Rider throws the following error:
Error MSB3073: The command "npm i" exited with code 127. (MSB3073)
Details in the log:
Target SassBuild:
npm i
/var/folders/9l/d02_tk1j5f93vklft82p1z996dm09b/T/tmp89785a0aeebb4347a3696de11d8c281e.exec.cmd: line 2: npm: command not found
PATH_TO_CSPROJ_HERE.csproj(232,5): error MSB3073: The command "npm i" exited with code 127.
Done building target "SassBuild" in project "X.csproj" -- FAILED.
npm
is installed already and I can run the npm commands in terminal. I use nvm
for node versioning.
Any ideas?
Alright, I figured out that Mac OS terminal and VS/Rider terminals are not fed from the same terminal configuration files; that's why the IDEs weren't able to find the npm in their paths.
I copied all the nvm
related configuration from ~/.zprofile
to ~/.profile
and now I am able to build the project in VS/Rider.
Hope it helps anyone having the same problem.