javascript - 如果我不是 Sudo,React-Native 无法运行项目

标签 javascript android react-native terminal jsx

我无法使用代码react-native run-android运行react-native项目。我收到以下错误

info Starting JS server...
info Building and installing the app on the device (cd android && ./gradlew app:installDebug)...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not create service of type AnnotationProcessorDetector using JavaGradleScopeServices.createAnnotationProcessorDetector().

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
error Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
error Command failed: ./gradlew app:installDebug. Run CLI with --verbose flag for more details.

但是如果我以root身份运行它“sudo react-native run-andoid”,它就会运行。

如何让项目在没有root权限的情况下运行?

最佳答案

我通过阅读post发现by Medium 指出,当您在安装 React Native 和相关工具时遇到权限问题时,您必须明确授予每个文件夹权限,以便您可以在无需 sudo 的情况下运行应用程序。否则 sudo 安装的文件只能作为 sudo 运行。

使用以下命令授予当前用户对该特定文件夹的访问权限

sudo chown -R $(whoami) ~/Documents/Myapplicationfolder

关于javascript - 如果我不是 Sudo,React-Native 无法运行项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56162662/

相关文章:

javascript - 使用用户脚本作为常规 JavaScript?

javascript - 如何使文本移动到 JQuery 幻灯片下方

android - 如何在 Android 固件中添加应用程序?

javascript - React js 从父组件更改子组件的状态

javascript - 如何使用小书签在新选项卡中启动功能?

javascript - 用js在android中打开 native 选择弹出窗口

java - 谁能帮我更正这段代码?

button - 使用样式化组件在 React Native 中动态样式化按钮

android - 如何从 native android传递数据以响应 native ?

android - 如何停止背景音乐播放? ( react native 声音)