2

I've installed Visual Studio for Mac community 8.10.11 and created a new Project based on React + .net Core WebAPI. But If I try to run the app, I got

/Users/xxx/Projects/yyy/yyy/yyy.csproj(5,5): Warning MSB3073: The command "node --version" exited with code 127. (MSB3073) (yyy)
/Users/xxx/Projects/yyy/yyy/yyy.csproj(5,5): Warning MSB4181: The "Exec" task returned false but did not log an error. (MSB4181) (yyy)
/Users/xxx/Projects/yyy/yyy/yyy.csproj(5,5): 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. (yyy)

My bash knows node and the folder is also part of echo $path. How can I add it to VS?

Thanks!

Gerrit
  • 2,515
  • 5
  • 38
  • 63
  • Visual Studio for Mac has a different PATH to the terminal due to how GUI apps run on macOS. Where is node installed? You should be able to use 'which node' to see. I have node installed in /usr/local/bin/node' which is found by VS Mac. So adding a symlink there to where you have node installed may solve the problem you are having. – Matt Ward Oct 29 '21 at 14:04

2 Answers2

2

I experienced the same issue because I used homebrew to install Node.js.

According to the Homebrew documentation:

GUI apps on macOS don’t have Homebrew’s prefix in their PATH by default. If you’re on Mountain Lion or later, you can fix this by running sudo launchctl config user path "$(brew --prefix)/bin:${PATH}" and then rebooting, as documented in man launchctl. Note that this sets the launchctl PATH for all users.

If you installed node from elsewhere, you should be able to modify this command to include the path to wherever your node executable is:

sudo launchctl config user path "<path-to-bin-folder>:${PATH}"
Joshua Breeden
  • 1,844
  • 1
  • 16
  • 29
0

I agree with Joshua answer, if you installed Node with Homebrew or Nvm

/usr/local/bin doesn't has node link.

Only add in your terminal:

sudo ln -s "$(which node)" /usr/bin/node
sudo ln -s "$(which npm)" /usr/bin/npm

React-request-timeout-period-of-50-seg

Danner Gv
  • 1
  • 2