Problem verifying node installation in m1 pro mac while setting up Visual Studio
Asked Answered
P

1

0

I am trying to setup Visual studio 2019 for .Net development with Vue.js in a M1 pro mac arm64. I have a starter code that my team member provided. They use a window machine and they are running it without issue. However, when I try to build the project I keep getting an error saying that Node was not installed. Error in visual studio

I am pretty sure I installed it because I regularly use to run React apps. It is running in the intel mode right now but it gives the same response for the arm64 mode as well. I would like to point out that I have used nvm to install my node package. This is my console output in the terminal for vscode:

prabalchhatkuli@Prabals-MacBook-Pro TimeTracking % node --version
v14.17.5
prabalchhatkuli@Prabals-MacBook-Pro TimeTracking % which node
/Users/prabalchhatkuli/.nvm/versions/node/v14.17.5/bin/node
prabalchhatkuli@Prabals-MacBook-Pro TimeTracking % arch
i386
prabalchhatkuli@Prabals-MacBook-Pro TimeTracking % 

And I am trying to run this part of the .csproj file:

<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>

I don't have an explanation for this because the node --version works in the rosetta2 terminal as well as the native terminal.

Pus answered 1/3, 2022 at 5:51 Comment(2)
Were you able to solve this issue? What steps did you take?Acquah
@Acquah couldn’t find any solution for that project. I created a new vue project and put it in. That worked for me.Pus
A
4

This answer resolves the issue: https://mcmap.net/q/92480/-cannot-install-nodejs-usr-bin-env-node-no-such-file-or-directory. Turns out node wasn't in my /usr/local/bin directory so I created a symlink

ln -s "$(which node)" /usr/local/bin/node
Acquah answered 12/4, 2022 at 9:16 Comment(1)
similar approach solves the problem with npm on VS for Mac 2022 ln -s "$(which npm)" /usr/local/bin/npmSpates

© 2022 - 2024 — McMap. All rights reserved.