【问题标题】:How Can I Solve Permission Denied in React Native Project?如何解决 React Native 项目中权限被拒绝的问题?
【发布时间】:2020-02-18 08:22:28
【问题描述】:

任何人在跑步后都遇到过这个问题

react-native run-android/ios

android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java (权限被拒绝)

当我在像npm install/yarn add etc 这样的任何命令之前写sudo 时,它工作得很好

否则我得到了与权限相关的错误

【问题讨论】:

    标签: macos shell react-native sudo


    【解决方案1】:
    • 您可以查看android/gradlew

    • 的权限
    • 它们应该是 755 而不是 644

    • 在您的应用根文件夹中运行 chmod 755 android/gradlew 然后运行 ​​react-native run-android

    • 它应该又可以工作了

    • 最后移除节点模块并使用rm -rf node_modules && npm install

    • 重新安装

    【讨论】:

    • 遗憾的是,我收到的警告与我在@AnasM.I Answer 中所说的相同
    • @OliverD 在您的项目根文件夹中运行 chmod 代码,例如:如果您的项目是“音乐”,则在您的“音乐”项目文件夹中运行此代码
    • 是的,我做到了:)
    • 运行你的命令后我没有收到任何错误,但在我运行我的应用程序后,我在 Metro bundler warn Failed to chmod xsel: EPERM: operation not permitted, chmod '/Volumes/Work/Works/client-4/music/node_modules/@react-native-community/cli/build/commands/server/external/xsel' 中收到警告
    • 试试这个 -> rm -rf node_modules && npm install
    【解决方案2】:

    您似乎没有权限-试试这个

    sudo chmod -R 777 {路径}

    【讨论】:

    • 只需添加您的路径即可。顺便说一句 sudo react-native run-android/ios 对你有用吗?
    • 运行您的命令后,我在打包时收到此警告warn Failed to chmod xsel: EPERM: operation not permitted, chmod '/Volumes/Work/Works/client-4/music/node_modules/@react-native-community/cli/build/commands/server/external/xsel'
    • 我认为没有,sudo chmod -R 777 /Volumes/Work/Works/client-4/music
    【解决方案3】:

    从项目中删除 node_modules 文件夹,然后运行命令 npm i 在现有的 react-native 项目中为我工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-19
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      • 2021-05-24
      相关资源
      最近更新 更多