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

packager.sh seems to not find node binary when using NODE_BINARY variable #22868

Closed
3 tasks done
Nabellaleen opened this issue Jan 4, 2019 · 2 comments
Closed
3 tasks done
Labels
Bug Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Platform: Linux Building on Linux. Priority: Low Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@Nabellaleen
Copy link

Nabellaleen commented Jan 4, 2019

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.19 Fedora 29 (Twenty Nine) 29 (Twenty Nine)
      CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
      Memory: 3.14 GB / 15.55 GB
      Shell: 4.4.23 - /bin/bash
    Binaries:
      Node: 11.4.0 - ~/.local/share/virtualenvs/luko-app-react-native-wkPbUArk/bin/node
      npm: 6.5.0 - ~/.local/share/virtualenvs/luko-app-react-native-wkPbUArk/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        API Levels: 23, 26, 27, 28
        Build Tools: 27.0.3, 28.0.3
        System Images: android-27 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
    npmPackages:
      react: ^16.6.3 => 16.7.0 
      react-native: ^0.57.8 => 0.57.8 

Description

In https://github.com/facebook/react-native/blob/master/scripts/packager.sh node is called directly, without using the one defined by NODE_BINARY variable

So, when using other alternatives than nvm or nodenv (I use nodeenv, but in a pipenv python virtualenv, to be fully isolated from the system), XCode fail, telling node is not found

Reproducible Demo

To setup a virtualenv as I did :

Install python pipenv tool at user level:

pip install -u pipenv

Then setup a virtualenv and activate node

cd my_src_directory
pipenv --python 3
pipenv shell
pipenv install --dev nodeenv
nodeenv -p

Setup the react-native stack

npm install

Retrieve the virtualenv path

pipenv --venv

Configure xcode shell script for react native building with NODE_BINARY using the virtualenv path (+ bin/ subdirectory) then try to build => Error

@react-native-bot react-native-bot added Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. Platform: Linux Building on Linux. labels Jan 4, 2019
@hramos hramos removed the Bug Report label Feb 6, 2019
@bartolkaruza
Copy link

Hi there, thank you for reporting the issue. It looks like that should indeed be using the binary from the env var instead of the node binary directly. We are happy to receive a PR for this change!

@bartolkaruza bartolkaruza added Priority: Low Good first issue Interested in collaborating? Take a stab at fixing one of these issues. labels Mar 19, 2019
@Esemesek
Copy link
Contributor

Esemesek commented Mar 26, 2019

@Nabellaleen I managed to get this flow working. I have followed all the steps you mentioned - configured venv, installed nodeenv, and changed the build script. Everything seems to be working for me though. This is my script from Bundle React Native code and images:

export NODE_BINARY=/Users/kacper/.local/share/virtualenvs/nodeEnv-MMkSE-Jx/bin/node
../node_modules/react-native/scripts/react-native-xcode.sh

I even managed to get things working with:

cd ..
pipenv shell
export NODE_BINARY=$(pipenv --venv)/bin/node
cd -
../node_modules/react-native/scripts/react-native-xcode.sh

My react-native info:

  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
      Memory: 130.64 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.12.0 - ~/.local/share/virtualenvs/nodeEnv-MMkSE-Jx/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.7.0 - ~/.local/share/virtualenvs/nodeEnv-MMkSE-Jx/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 27, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3
        System Images: android-24 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.2 => 0.59.2

EDIT: This flow works for me, but I don't think that I am using the correct version of node under the hood. We should replace direct node call and replace it with NODE_ENV.

dsyang pushed a commit to dsyang/react-native that referenced this issue Apr 12, 2019
Summary:
Fix packager script to use `NODE_BINARY` env variable.

Should fix facebook#22868

[iOS] [Fixed] - Use `NODE_BINARY` env variable in `packager.sh` script
Pull Request resolved: facebook#24156

Differential Revision: D14870783

Pulled By: cpojer

fbshipit-source-id: 27ecf8bf59883920ab51478b8a4d8f0780e34664
@facebook facebook locked as resolved and limited conversation to collaborators Apr 10, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Apr 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Platform: Linux Building on Linux. Priority: Low Resolution: Locked This issue was locked by the bot. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants