-
Notifications
You must be signed in to change notification settings - Fork 577
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
npm use in build.gradle when using Android Studio #687
Comments
I met the same problem. |
I have this issue as well. |
Having the same issue, I wasn't even aware it was related to Realm. |
This would be great to get fixed pretty soon. It makes it hard to work in Android Studio. |
i have the same issue. |
Same here, changing to |
Hi @davidstoker Android Studio doesn't inherit the environment variables you defined in your shell. In your case a quick work around, is to start Android Studio from the shell (ex: on OSX) Cheers |
In my macOS Sierra, the following works for me.
|
@zhenglingxiao what is that |
In macOS Sierra,this is System Integrity Protection. If we don't run |
I am also having this issue, I am using a non standard RN directory structure (in which my android project is located somewhere else). |
Hi @jatazoulja I don't see how this could be an issue for CI, I believe you're not using AndroidStudio within your CI machine to build your project, and you're rather building from command line which should find Cheers, |
is it possible to manually set the path for that command like you would on the shell? Something like: Gradle won't accept this particular syntax, but there may be some variation that does work properly. While the workarounds do handle this, nearly every Realm developer who's targeting iOS with React Native is going to run into this problem. Unless this is really well documented, it's going to frustrate a lot of people. |
Having the same problem on windows as well. |
Same here, darn. |
Was seeing this problem on windows even though npm was in the path. Was able to resolve the issue by adding the npm file extension (see below).
|
What about nvm users? Why not read version directly from package like the applicationId? The npm command only echoes the version anyways. |
this should be fixed by #849 |
👍 |
Is anybody here still having trouble with this or can I close it? |
I'm still having the trouble (mac user) |
@evollu Can you check you are using the latest version of realm? I can't reproduce the issue with the latest changes on mac. |
@blagoev with android studio? |
@evollu Yep. Android Studio builds and runs the project fine. Can you check this file in your project then try finding the getNpmVersion function in that file it should contain this fix If it does and you are still not able to build from within Android Studio then there is something else going on in your project. Also you can try creating a new default react native app just to test the fix is working within Android Studio for the new app. |
yeah i tested in 1.1.1 and everything seems fine |
thanks, closing this one |
An error is being thrown by the use of npm in this line of the build.gradle:
version = "npm --silent run get-version".execute(null, projectDir).text.trim()
I am using this in a React Native project. I typically build from the command line but attempted to build in Android Studio and the build fails with this error since it can't find the npm executable:
Cannot run program "npm" (in directory "/Users/<directory>/node_modules/realm/android"): error=2, No such file or directory
The default path for a GUI application like Android Studio on macOS is:
/usr/bin:/bin:/usr/sbin:/sbin
In my case, npm is in
/usr/local/bin
installed through homebrew.If I change the command to a full path then it builds correctly:
version = "/usr/local/bin/npm --silent run get-version".execute(null, projectDir).text.trim()
Any suggestions for handling this in the publish_android_template instead of me manually correcting this?
The text was updated successfully, but these errors were encountered: