解决 Error: spawnSync ./gradlew EACCES

在跑 react-native 项目时遇到如下错误


info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1444 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: spawnSync ./gradlew EACCES
    at Object.spawnSync (internal/child_process.js:1002:20)
    at spawnSync (child_process.js:614:24)
    at execFileSync (child_process.js:642:13)
    at runOnAllDevices (/data/app/dongdianmei/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:75:39)
    at buildAndRun (/data/app/dongdianmei/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:169:41)
    at then.result (/data/app/dongdianmei/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:135:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)

Screenshot from 2019-07-19 00-21-32.png

我们看到实际的错误就是 Error: spawnSync ./gradlew EACCES 一番搜索之后,发现其实是 gradlew 没有执行权限

我们给它个 755 权限试试,sudo chmod +x ./android/gradlew 其实这个 gradlew 才是 android 构建的关键…

好了,这次的坑就踩到这里,下次见…

日记本

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

赞赏支持
被以下专题收入,发现更多相似内容