ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126
Environment
react-native info output
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 941.36 MB / 64.00 GB
Shell:
version: 3.6.0
path: /opt/homebrew/bin/fish
Binaries:
Node:
version: 18.18.0
path: ~/.volta/tools/image/node/18.18.0/bin/node
Yarn:
version: 3.6.4
path: ~/.volta/tools/image/yarn/1.22.18/bin/yarn
npm:
version: 9.8.1
path: ~/.volta/tools/image/node/18.18.0/bin/npm
Watchman:
version: 2024.08.26.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK:
API Levels:
- "31"
- "32"
- "33"
- "34"
Build Tools:
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
System Images:
- android-31 | Google TV ARM 64 v8a
- android-32 | Google APIs ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: javac 17
path: /Users/liam/.jabba/jdk/[email protected]/Contents/Home/bin/javac
Ruby:
version: 3.3.4
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli":
installed: 14.0.1
wanted: ^14.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native: Not Found
react-native-macos: Not Found
react-native-tvos:
installed: 0.75.2-0
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Description
I'm seeing a similar problem as https://github.com/react-native-community/cli/issues/2490 but with a different exit code.
Caused by: org.gradle.api.GradleException: ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 126
Which usually means a permissions issue. I can run npx @react-native-community/cli config myself with no issues.
This comment https://github.com/react-native-community/cli/issues/2490#issuecomment-2323146345 mentions making rnc-cli executable but mine already is executable.
Same error as this comment https://github.com/facebook/react-native/issues/46134#issuecomment-2316052971 but that issue is unrelated so suggested fixes don't work.
When I run the build from android studio it doesn't run into this (but does error about dependencies being built against wrong SDK version so I can't complete a build from there).
I've tried ./gradlew clean but that results in the same error, I've deleted node_modules and lockfile, I've tried looking manually at the cli bin files for permission issues, I've updated android studio, I'm using latest SDK.
I tried running as root and then it was able to build, but that causes a bunch of other issues related to file ownership being owned by root.
Building when running on emulator (from react-native start) works fine and I can work on the app like normal.
This began happening updgrading from 0.73.7 to 0.75.2 (through the react-native-tvos project).
This happens when building using
./gradlew assembleRelease
I'm using volta to manage node versions
Reproducible Demo
I was able to reproduce in a fresh project
$ npx @react-native-community/cli init testproject
$ cd testproject
$ yarn
$ cd android
$ ./gradlew assembleRelease --info --verbose --full-stacktrace
react-native info output
System:
OS: macOS 14.2.1
CPU: (10) arm64 Apple M1 Max
Memory: 305.52 MB / 64.00 GB
Shell:
version: 3.6.0
path: /opt/homebrew/bin/fish
Binaries:
Node:
version: 18.17.1
path: ~/.volta/tools/image/node/18.17.1/bin/node
Yarn:
version: 3.6.4
path: ~/.volta/tools/image/yarn/1.22.18/bin/yarn
npm:
version: 9.6.7
path: ~/.volta/tools/image/node/18.17.1/bin/npm
Watchman:
version: 2024.08.26.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.14.3
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.5
- iOS 17.5
- macOS 14.5
- tvOS 17.5
- visionOS 1.2
- watchOS 10.5
Android SDK:
API Levels:
- "31"
- "32"
- "33"
- "34"
Build Tools:
- 30.0.3
- 31.0.0
- 33.0.0
- 33.0.1
- 34.0.0
System Images:
- android-31 | Google TV ARM 64 v8a
- android-32 | Google APIs ARM 64 v8a
- android-33 | Google APIs ARM 64 v8a
Android NDK: Not Found
IDEs:
Android Studio: 2024.1 AI-241.18034.62.2412.12266719
Xcode:
version: 15.4/15F31d
path: /usr/bin/xcodebuild
Languages:
Java:
version: javac 17
path: /Users/liam/.jabba/jdk/[email protected]/Contents/Home/bin/javac
Ruby:
version: 3.3.4
path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.75.2
wanted: 0.75.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: false
Building with react-native build-android --mode release works but I'm trying to generate an apk file not an aab file.
Downgrading from gradle 8.8 to 8.7 seems to have fixed things but I also had it working on 8.8 somehow, and then it broke again, so I'll see how long this keeps working.
I had upgraded gradle to 8.8 following the upgrade helper diff https://react-native-community.github.io/upgrade-helper/?from=0.73.7&to=0.75.2#RnDiffApp-android-gradle-wrapper-gradle-wrapper.properties
Well that didn't last long, tried another build after working on the app and the same error has returned.
Running ./gradlew -stop and then starting a new build seems to work.
I believe this issue is related to the new version. Last night, a friend and I spent a considerable amount of time troubleshooting, and after extensive efforts, my friend suggested that we try creating the project using the following command:
npx @react-native-community/cli@latest init ProjectName --version 0.74.5
After creating the project with this command, the issue was successfully resolved.
I just ran into the same issue.
For me, doing a chmod +x on the rnc-cli made it work again.
I also tried running the init as suggested above before doing the permission thingy, that didn't solve it for me 🤷♂️
@winterdouglas what OS are you using?
@winterdouglas what OS are you using?
MacOS Sonoma (14.6.1)
@winterdouglas in your case does it also happen in fresh projects?
@winterdouglas in your case does it also happen in fresh projects?
Hm, I haven't tried that before, but doing it now worked right away for a new project.
Sounds very similar to my trouble with it since upgrading to v0.75.2 (but I'm getting 127 error code): https://github.com/react-native-community/cli/issues/2484
I am also getting same Error in using any new module when I download any new module it show the error ERROR: autolinkLibrariesFromCommand: process cmd /c npx @react-native-community/cli config exited with error code: 1. Can any one suggest how to solve this
@cripttion an easy workaround is to do chmod u+x node_modules/@react-native-community/cli/build/*.js whenever you bump into this error after updating node modules.
@birdofpreyru I am using Windows OS can you give any suggestion for this.
@cripttion sure, don't use Windows for RN (nor for any other non-Windows) development :rofl:
I added the package attribute to the AndroidManifest.xml
Updated my project dependencies by adding @react-native-community/cli:
"@react-native-community/cli": "^14.1.1" Deleted the node_modules folder and reinstalled the dependencies by running:
Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:
./gradlew -stop ./gradlew clean After doing this, my build started working successfully.
I faced this issue, too. I could run my app without any issue yesterday though.
P.S. adirimia92's suggestion worked for me. Thank you.
I just ran into the same issue. For me, doing a
chmod +xon thernc-climade it work again. I also tried running theinitas suggested above before doing the permission thingy, that didn't solve it for me 🤷♂️
It looks like permissions issue as I did the same:
chmod +x /Users/[RN-PROJECT-PATH]/node_modules/.bin/rnc-cli
and the build started without the reported error...
I added the package attribute to the AndroidManifest.xml
Updated my project dependencies by adding @react-native-community/cli:
"@react-native-community/cli": "^14.1.1" Deleted the node_modules folder and reinstalled the dependencies by running:
Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:
./gradlew -stop ./gradlew clean After doing this, my build started working successfully.
I just ran these two commands for gradle and it worked without the other changes 👍
In the process though I also updated Android Studio, updated all SDKs, deleted node_modules and reinstalled. Hopefully none of those things you'll need to repeat.
Using Node 20 solve my issue
I added the package attribute to the AndroidManifest.xml
Updated my project dependencies by adding @react-native-community/cli:
"@react-native-community/cli": "^14.1.1" Deleted the node_modules folder and reinstalled the dependencies by running:
Navigated to the Android folder and ran the following Gradle commands to stop and clean the build:
./gradlew -stop ./gradlew clean After doing this, my build started working successfully.
./gradlew clean is giving me the same error:
ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1
FAILURE: Build failed with an exception.
-
Where: Settings file '/Users/[path-to-file]/settings.gradle' line: 3
-
What went wrong: A problem occurred evaluating settings 'pangea'.
ERROR: autolinkLibrariesFromCommand: process npx @react-native-community/cli config exited with error code: 1
- 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
.bin/rnc-cli
Worked Like a Magic!
我在AndroidManifest.xml中添加了package属性 通过添加@react-native-community/cli更新了我的项目依赖项: “@react-native-community/cli”:“^14.1.1” 删除 node_modules 文件夹并通过运行重新安装依赖项: 导航到 Android 文件夹并运行以下 Gradle 命令来停止并清理构建: ./gradlew -stop ./gradlew clean 完成此操作后,我的构建开始成功运行。
./gradlew clean 给了我同样的错误:
错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1
失败:构建因异常而失败。
- 其中: 设置文件'/Users/[path-to-file]/settings.gradle' 行:3
- 出了什么问题: 评估“pangea”设置时出现问题。
错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整见解。在https://help.gradle.org 上获取更多帮助。
1 秒内构建失败
我遇到了同样的问题
Guys who are looking for solutions to this, then just uninstall node_modules and install the dependencies again. Something strange happens with cli when switching to other branches.
rm -rf node_modules && yarn
./gradlew -stop
a new project really works, but when copying the android folders, etc. from the new architecture to try to keep the old project updated, it simply doesn't work, that's crazy.
我在AndroidManifest.xml中添加了package属性 通过添加@react-native-community/cli更新了我的项目依赖项: “@react-native-community/cli”:“^14.1.1” 删除 node_modules 文件夹并通过运行重新安装依赖项: 导航到 Android 文件夹并运行以下 Gradle 命令来停止并清理构建: ./gradlew -stop ./gradlew clean 完成此操作后,我的构建开始成功运行。
./gradlew clean 给了我同样的错误: 错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1 失败:构建因异常而失败。
- 其中: 设置文件'/Users/[path-to-file]/settings.gradle' 行:3
- 出了什么问题: 评估“pangea”设置时出现问题。
错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整见解。在https://help.gradle.org 上获取更多帮助。
1 秒内构建失败
我遇到了同样的问题
sameProblem...when i have added some packages and rebuild the project, it failed, with code 1, it confused me for 2 hours...
我在AndroidManifest.xml中添加了package属性 通过添加@react-native-community/cli更新了我的项目依赖项: “@react-native-community/cli”:“^14.1.1” 删除 node_modules 文件夹并通过运行重新安装依赖项: 导航到 Android 文件夹并运行以下 Gradle 命令来停止并清理构建: ./gradlew -stop ./gradlew clean 完成此操作后,我的构建开始成功运行。
./gradlew clean 给了我同样的错误: 错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1 失败:构建因异常而失败。
- 其中: 设置文件'/Users/[path-to-file]/settings.gradle' 行:3
- 出了什么问题: 评估“pangea”设置时出现问题。
错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整见解。在https://help.gradle.org 上获取更多帮助。
1 秒内构建失败
我遇到了同样的问题
sameProblem...when i have added some packages and rebuild the project, it failed, with code 1, it confused me for 2 hours...
Here it was a permissions problem, I even found a topic saying how to remove the node_modules folder and reinstall, with that working
我在AndroidManifest.xml中添加了package属性 通过添加@react-native-community/cli更新了我的项目依赖项: “@react-native-community/cli”:“^14.1.1” 删除 node_modules 文件夹并通过运行重新安装依赖项: 导航到 Android 文件夹并运行以下 Gradle 命令来停止并清理构建: ./gradlew -stop ./gradlew clean 完成此操作后,我的构建开始成功运行。
./gradlew clean 给了我同样的错误: 错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1 失败:构建因异常而失败。
- 其中: 设置文件'/Users/[path-to-file]/settings.gradle' 行:3
- 出了什么问题: 评估“pangea”设置时出现问题。
错误:autolinkLibrariesFromCommand:进程 npx @react-native-community/cli 配置退出,错误代码:1
- 尝试:
使用 --stacktrace 选项运行以获取堆栈跟踪。 使用 --info 或 --debug 选项运行以获取更多日志输出。 使用 --scan 运行以获取完整见解。在https://help.gradle.org 上获取更多帮助。
1 秒内构建失败
我遇到了同样的问题
sameProblem...when i have added some packages and rebuild the project, it failed, with code 1, it confused me for 2 hours...
Here it was a permissions problem, I even found a topic saying how to remove the node_modules folder and reinstall, with that working
It seems like the original node_modules packages works fine, but the third-party can't,and there must be something wrong with the auto link function, could i add my packages manually?(though it might be tedious)or there is a better way to solve the permission problem?
I am also getting same Error in using any new module when I download any new module it show the error ERROR: autolinkLibrariesFromCommand: process cmd /c npx @react-native-community/cli config exited with error code: 1. Can any one suggest how to solve this
I uninstalled the old version and install the latest version of react-native-community/cli, as for the config problem , i ran it isolatedly and found that the android/app/main/AndroidManifest.xml don't have my package name, so i add it like this:
As Paurox mentioned, the package name/namespace seems to affect this issue. I had also encountered this issue multiple times so far, and the cause seems to alter everytime. The main problem, as the error mentioned, is that npx @react-native-community/cli config doesn't provide a correct output due to some reasons. This could be a permission issue, or the command actually doesn't work, or in rare cases, you may need to update the settings.gradle file, and lastly, you may also have an outdated nodejs version like 16.
The permission issue can be ressolved by using chmod or run as admin on Windows (not recommended though). When the command doesn't work, try updating @react-native-community/cli to the latest version because the latest 0.76.3 template uses a version, 15.0.1, which doesn't work at least for me. In the third case, it is probably due to the folder structure, so the autolinkLibrariesFromCommand function needs to be updated like the following:
// If using .gradle.kts files:
extensions.configure<com.facebook.react.ReactSettingsExtension> {
// https://reactnative.dev/docs/integration-with-existing-apps?language=kotlin#configuring-gradle
// have to update the path for it to run
autolinkLibrariesFromCommand(
workingDirectory = file("../../existing/"), <- here point to the react native folder
lockFiles = files("../../existing/package-lock.json", "../../existing/package.json") <- provide lock files here
)
}
See the whole settings.gradle
Also, make sure the node version is up to date, I had node 16 previously, so it worked until it didn't. Try the good old remove node_modules could be another way. I also had some issues due to nvm, somehow Xcode or Android Studio couldn't locate the correct version and was using the system node.
I was getting this issue when running autolinkLibrariesFromCommand() when upgrading to 0.76.6 from 0.73.7 in My Brownfield ReactNative setup
process npx @react-native-community/cli config exited with error code: 1
Solution: https://github.com/facebook/react-native/issues/47154#issuecomment-2626522995