11

I'm getting the following build error when compiling my react-native project in Xcode env: node: No such file or directory

Not sure whats causing it? Node v8.9.4 React-Native v0.50.4 NPM v5.6.0 And I'm using nvm

Almog
  • 2,327
  • 5
  • 28
  • 56
  • Got it working by following the following - https://stackoverflow.com/questions/43465086/env-node-no-such-file-or-directory-in-mac – Almog Mar 01 '18 at 01:36

5 Answers5

44

if you are using nvm do

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

this will link current nvm to your usr local and next time Xcode will find the correct node path and version

Luis
  • 813
  • 8
  • 15
  • 1
    just to confirm this was the solution for me in July 2021 - xcode 12.5.1 – Jonatas CD Jul 27 '21 at 12:17
  • 2
    This is a great solution. Just one thing to keep in mind: it will specifically set the version of Node that XCode knows about to the one you currently have activated. If you ever switch versions of node using NVM, you should re-run this command so that XCode is symlinked to that same version – Robert Townley Oct 20 '21 at 14:56
  • This is the right answer, on xcode 13. Caused by xcode not being able to find node (nvm) – Desmond Jan 09 '22 at 13:21
  • Right answer for me too! It's also written in the readme file =) – Don Diego Feb 03 '22 at 15:45
2

Here is one of the solutions for this error if you're using nvm and sentry: https://docs.sentry.io/clients/react-native/manual-setup/#using-node-with-nvm

Huy Vo
  • 2,318
  • 6
  • 26
  • 43
2

Xcode have some issues finding node from nvm, try this inside the script that throws the error:

# Setup nvm and set node
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"

if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
. "$HOME/.nvm/nvm.sh"
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
. "$(brew --prefix nvm)/nvm.sh"
fi

[ -z "$NODE_BINARY" ] && export NODE_BINARY="node"

$NODE_BINARY ../node_modules/@sentry/cli/bin/sentry-cli upload-dsym

user2976753
  • 905
  • 11
  • 23
  • This solution worked for me running React Native >= 0.60 with sentry-react-native version 1.7.2. Navigate to Build Phases --> Bundle React Native code and images – Brian Li Sep 04 '20 at 05:57
1

In my case, this was related to an old sentry configuration and the fact that I use nvm.

Following https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/

you should be able to execute ln -s $(which node) /usr/local/bin/node and get it fixed

0

Add this at the top of the script that's failing (in Project -> build phases):

. ~/.nvm/nvm.sh
Andreas Bergström
  • 12,578
  • 5
  • 53
  • 48