i'm new to Asp.Net Core, Visual Studio and so on. A project i'm working on has an error which occurs just on my machine whenever i try to run the Solution. Here is the error:
The command "npm install && npm run build --prefix /my_path_to_project/MyProject.Web/" exited with code 127.
The error occurs in MyProject.Web.csproj
where i have something like:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="npm install && npm run build --prefix $(ProjectDir)" />
</Target>
The path of ProjectDir
is correct (at least looking from the error message).
I'm able to run successfully npm i && npm build
from my terminal in the project directory and from Visual Studio terminal.
But when i run the Solution i hit the error.
Removing those lines, the project runs properly.
I'm working on Mac 10.13
with Visual Studio 2019 v8.7
I have installed node and npm with nvm
node v12.18.3
npm v6.14.7
Does anyone ever had this problem? My guesses are:
- Visual Code cannot find where npm is on my machine (but i have no idea how to investigate in this)
- More rights are needed to run npm command, like sudo (very weird but at this point it might be)
Would be amazing if someone can explain me how Visual Studio find and run npm commands.
UPDATE It turn out that installing Node manually from source solved all the problems. Look like NVM install node in position that is not where VS go to search for it.
Does anyone use NVM with Visual Studio?? Would be very helpful