/usr/bin/env:'sh\r':运行react native时,linux中没有这样的文件或目录



我是过渡到linux的windows用户。我已经根据文档设置了环境和一切,但当我运行npx react native run android时,我会收到以下错误。解决方案是什么?我试着安装了运行dos2unix ./gradlew clean的dos2unix nad进行测试,结果显示找不到gradlew。环境变量和路径设置正确。

└─$ npx react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 1393 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Installing the app...
/usr/bin/env: ‘shr’: No such file or directory
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/usr/bin/env: ‘shr’: No such file or directory
at makeError (/media/muaz/Studios/stylon/node_modules/execa/index.js:174:9)
at /media/muaz/Studios/stylon/node_modules/execa/index.js:278:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runOnAllDevices (/media/muaz/Studios/stylon/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
at async Command.handleAction (/media/muaz/Studios/stylon/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:192:9)
info Run CLI with --verbose flag for more details.

p.S我打算同时使用这两个操作系统。我有双引导系统。

这很有效:

安装dos2unix

cd android && dos2unix ./gradlew 

最新更新