Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: find-node.sh now respects .nvmrc (#32712)
Summary: React-native Xcode build steps (such as "Build JS Bundle") rely on `find.node-sh` to find the correct node binary, using nvm if present. We do this because Xcode may run build steps in a fresh shell environment, presumably for repeatable builds. This PR fixes `find-node.sh`, to respect any `.nvmrc` file that may be present in the build environment. Today: `find-node.sh` will set the shell environment to the system node version, and ignores any `.nvmrc` the project may provide to pin node for repeatable builds. By ignoring `.nvmrc`, node versions may differ depending on system environment — between developer laptops, or between developer and CI environments. 😞 This problem has been been noticed before in #8887 ### Should this fix happen upstream? Unfortunately this nvm behavior [is intended](nvm-sh/nvm#2053), for backwards compatibility ## Changelog <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/Changelog --> [iOS] [Fixed] - find-node.sh now respects .nvmrc Pull Request resolved: #32712 Test Plan: Before: ```bash # nvm isn't loaded $ which nvm # we're on default system node $ which node && node --version /usr/local/bin/node v17.0.1 $ echo v16.13.0 > .nvmrc $ source ./scripts/find-node.sh # Expected: v16.13.0 $ node --version v17.0.1 ``` After: ```bash # we're on default system node $ which node && node --version /usr/local/bin/node v17.0.1 $ echo v16.13.0 > .nvmrc $ source ./scripts/find-node.sh # Expected: v16.13.0 $ node --version v16.13.0 ``` After (no .nvmrc, should preserve previous behavior): ```bash # we're on default system node $ which node && node --version /usr/local/bin/node v17.0.1 $ source ./scripts/find-node.sh $ nvm ls|grep default default -> v14.17.1 # Expected: v14.17.1 $ node --version v14.17.1 ``` Reviewed By: sota000 Differential Revision: D32889629 Pulled By: ShikaSD fbshipit-source-id: 527384055e303a87bad43413fb66a7fd117d1a63
- Loading branch information