Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode is having trouble finding node #475

Closed
maharjanaman opened this issue Jun 14, 2021 · 10 comments
Closed

Xcode is having trouble finding node #475

maharjanaman opened this issue Jun 14, 2021 · 10 comments

Comments

@maharjanaman
Copy link

When I try to build react-native project on xcode, I get

env: node: No such file or directory 
Command PhaseScriptExecution failed with a nonzero exit code

On shell(zsh), I don't have any trouble with node and which node print outs /var/folders/nz/hh7gg42x1tjf443r4fq3xylm0000gn/T/fnm_multishells/33995_1623643112968/bin/node.

Is there anything I'm missing during installation process?

@joeyfigaro
Copy link

Having same issue. I tried updating RN to make use of their find-node.sh script, but it looks like it's looking for NODE_BINARY, which is undefined. Is there a recommended way to keep NODE_BINARY pointing to the current version used by fnm?

@maharjanaman
Copy link
Author

maharjanaman commented Jun 19, 2021

@joeyfigaro Was able to run the project by installing another node version using brew i.e. brew install node, which then acts as system node.
If there is any other better alternative, do let us know.

@Schniz
Copy link
Owner

Schniz commented Aug 3, 2021

duplicate of #486 (please reopen if I'm getting this wrong)

@Schniz Schniz closed this as completed Aug 3, 2021
@douglasjunior
Copy link

For nvm we can just run ln -s $(which node) /usr/local/bin/node to create a link to node binary, but with fnm this dont work. 😢

@Schniz
Copy link
Owner

Schniz commented Aug 11, 2021

You can run ln -s "$(realpath $(which node))" /usr/local/bin/node, but I am not sure I would suggest so.

Example:

$ echo "$(realpath $(which node))"
/Users/<username>/.fnm/node-versions/v14.15.4/installation/bin/node

@douglasjunior
Copy link

Thanks @Schniz this looks good.

And about husky js, any suggestions?

I tried to add export PATH=$HOME/.fnm:$PATH to the ~/.huskyrc, but don't work.

@taylorkline
Copy link

I thought about having an .xcode.local with:

export NODE_BINARY=/System/Volumes/Data/Users/username/Library/Application Support/fnm/aliases/lts-hydrogen/bin/node

This does not work due to the space in "Application Support" (even if escaped!)

However, a symlink ln -s /System/Volumes/Data/Users/username/Library/Application\ Support/fnm/aliases/lts-hydrogen/bin/node ~/node-18 allows for:

export NODE_BINARY=/Users/username/node-18

To work just fine.

@kud
Copy link

kud commented May 30, 2024

I've also got this issue with react-native.

For instance, the .xcode.env file is:

# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)

and my .xcode.env.local is:

export NODE_BINARY=/var/folders/07/scm1dt7n1sz2tk39cqfhvs7w0000gq/T/yarn--1717000088176-0.6543025354301102/node

so everytime I reboot my computer, it does not work anymore.

What I usually do is to remove the .xcode.env.local first and start the react-native command, and it works. But I would like to adjust for once .xcode.env.local instead of removing it everytime.

I would like to understand the difference between $(realpath $(which node)) and $(command -v node) it does not provide the same path:

echo "$(realpath $(which node))"
/Users/mest001/Library/Application Support/fnm/node-versions/v20.11.1/installation/bin/node
echo "$(command -v node)"
/Users/mest001/Library/Caches/fnm_multishells/6417_1717061860945/bin/node

What's the best?

Thanks.

@kud
Copy link

kud commented May 30, 2024

I've tried that in my .xcode.env.local:

export NODE_BINARY=$(realpath $(which node))

Let me know if it's the best option.

@erkie
Copy link

erkie commented Feb 20, 2025

I added this to the ios/.xcode.env file (I wanted to be able to check in the env file so it wanted it to work in an environment without fnm as well). For some reason it wasn't sourcing the proper profile scripts so had to add that manually. 🤷

# No node? Try to load via fnm
if ! command -v node &> /dev/null; then
  output=$(zsh -l -c 'source ~/.profile; source ~/.zshrc; eval "$(fnm env --shell=zsh)" && fnm env')
  eval "$output"

  # if no node is found throw an error
  if ! command -v node &> /dev/null; then
      echo "Node could not be found: $SHELL $USER $HOME"
      exit 1
  fi
fi

export NODE_BINARY="$(realpath $(which node))"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants