React Native 0.69生成Android Sourcemap命令报错求助
解决React Native 0.69.1生成Android Sourcemap的命令错误问题
你遇到的zsh: command not found错误,是因为原命令的换行格式不符合zsh的解析规则——反斜杠后面如果带有空格,会被当成转义后的空格处理,导致换行后的--entry-file等参数被识别成独立命令,而非npx react-native bundle的参数。
正确的命令写法
可以直接使用单行命令:
npx react-native bundle --platform android --entry-file index.js --dev false --bundle-output ./android/index.android.bundle --sourcemap-output ./android-sourcemap.json && zip ./android-sourcemap.zip ./android-sourcemap.json
如果需要换行排版,必须保证反斜杠后紧跟换行、无任何空格:
npx react-native bundle --platform android \ --entry-file index.js \ --dev false \ --bundle-output ./android/index.android.bundle \ --sourcemap-output ./android-sourcemap.json && \ zip ./android-sourcemap.zip ./android-sourcemap.json
额外排查要点
- 确认项目根目录下存在
index.js,如果你的项目入口是index.android.js或App.js,需要替换--entry-file的对应值 - 必须在项目根目录下执行命令
- 若出现权限错误,优先调整
./android目录的写入权限,而非直接使用sudo - 生成
android-sourcemap.zip后,登录Instabug后台找到对应Android应用的Sourcemap设置,上传该压缩包,注意要和你打包的APK版本对应
内容的提问来源于stack exchange,提问作者John Goodman
相关产品推荐
相关产品推荐

