sentry-cli: Supports NVM in sentry-cli.js when build from XCode (React Native) - node no such file or directory
Dependencies
{
"@babel/runtime": "^7.1.2",
"add": "^2.0.6",
"axios": "^0.18.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"lodash": "^4.17.10",
"mobx": "^4.3.1",
"mobx-react": "^5.1.0",
"moment": "^2.22.2",
"native-base": "^2.8.1",
"numeral": "^2.0.6",
"react": "16.6.0-alpha.8af6728",
"react-native": "0.57.1",
"react-native-contacts": "^2.2.4",
"react-native-fast-image": "^5.0.11",
"react-native-firebase": "^5.0.0",
"react-native-image-crop-picker": "^0.21.2",
"react-native-loading-spinner-overlay": "^0.5.2",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-sentry": "^0.39.1",
"react-navigation": "^2.12.1",
"schedule": "0.4.0"
}
Currently, the sentry wizard made following change to ProjectName.xcodeproj/project.pbxproj
- shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
+ shellScript = "export SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh\n";
This breaks RN apps with RVM with following error

The reason is scripts/react-native-xcode.sh can leverage nvm node executable in their script but the sentry-cli script didn’t
The fix was to copy the NVM handling part inside scripts/react-native-xcode.sh to build script to fix the above error.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 21 (2 by maintainers)
This is indeed still an issue
Looks like this is still a temporary solution that works: https://github.com/getsentry/react-native-sentry/issues/247
run this in your terminal - no edits required to project.pbxproj
It appears that the “no such file or directory” error is coming from the sentry-cli script, as it is a javascript script, and also runs with node:
The error is actually coming from
/usr/bin/env, hence why the error message starts with “env:”, because “/usr/bin/env” is not finding “node”.To confirm this, I changed this line of the build phase script :
To
Which should just print the help page of the command. I still see the error:
So the problem is that the
sentry-cliscript cannot find ournvm’snode.Why?
This is because for each build phase script, XCode will create a wrapper shell script and run it with a preset environment.
To see the the wrapper script, go to XCode’s report navigator after the build fails:
There are two notable things about this output. First, the
PATHis missing the path to thenvm’snode:Second is this:
After setting up a bunch of variables via
export ..., XCode runs the temporary script viash -c:The shell that runs the script is ran in non-interactive mode, which typically means it won’t read the “profile” files, including the call to initialize nvm.
I don’t know if this is the best solution, but one way to fix this is to initialize nvm in the build phase itself and then use it to set the node version to use:
Be sure to include the snippet in both Sentry build phases that call out to
../node_modules/@sentry/cli/bin/sentry-cli.Update: I was curious as to why this doesn’t affect the
react-native-xcode.shscript itself. It is because it has built-in support for nvm.Closing the issue, as it seems like the original issue has been partially resolved or there is a working solution. I’d prefer someone to create a new issue with a fresh description if it’s still an issue. Please do not hesitate to ping me if it is still relevant, and I will happily reopen it. Cheers!
Technically you have looked back if you’re here again 😉
2021, still an issue
thanks man! it really helps!