cli: Autolinking fails on Windows
Environment
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 9.61 GB / 15.89 GB
Binaries:
Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.16.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
Android NDK: 18.1.5063045
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5264788
Output of react-native --version
:
react-native-cli: 2.0.1
react-native: 0.60.0
Description
This is the error I am getting while running react-native run-android
or .\gradlew app:installDebug
:
:ReactNative:Cannot run program "./node_modules/.bin/react-native" (in directory "C:\Users\thecodrr\Source\Repos\Mysue\android\.."): CreateProcess error=2, The system cannot find the file specified
:ReactNative:Automatic import of native modules failed.
> Configure project :app
:ReactNative:Cannot run program "./node_modules/.bin/react-native" (in directory "C:\Users\thecodrr\Source\Repos\Mysue\android\.."): CreateProcess error=2, The system cannot find the file specified
:ReactNative:Automatic import of native modules failed.
I tried running the gradlew app:installDebug
command on Git Bash but still got the same error.
Reproducible Demo
- Create a new project using
react-native init
- Run
yarn add react-native-track-player@latest
- Run
yarn react-native run-android
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 80 (50 by maintainers)
Let’s get some facts straight:
@react-native-community/cli
is a dependency ofreact-native
. That makes it a “transitive dependency” of your project.react-native-cli
is a global package, we discourage to use it, it’s kind of a proxy to@react-native-community/cli
, but it’s a bit more complicated that that.Now that we know the facts:
Solution is to update your CLI version:
@react-native-community/cli
entry, remove it, runyarn install
/npm install
once againnode_modules
and runnpm install
again.npm list @react-native-community/cli
oryarn list @react-native-community/cli
and verify you’re on the latest version (above 2.1.0).After performing these steps you should be on the latest CLI version. Feel free to do it once in a while, because we release often.
Because that’s what’s happening behind the scenes in the
native_modules.gradle
. Autolinking basically gets your packages through this command.Yea, sorry for the confusion. We’re in a big transition period, things are moving fast, but we’re heading in a good direction, even if at times it seems like things get worse. It’s only temporary 😃
@mi5ha I don’t think they updated it correctly/fully after 0.60 release and after
npx
was added.@theweavrs @thymikee yes! I removed yarn.lock and run yarn again. this time, the error message gone.
@theweavrs If you follow what is written on official site you get the solution that doesn’t run, just saying… 😃
@zenz do what @thymikee said and if it still doesn’t work, try adding these in your
package.json
underdevDependencies
:Afterwards, do
yarn
ornpm i
@zenz @mi5ha @thymikee created one at #484
Works for me. The time for command execution varies though. Sometimes, it completes in a few seconds and sometimes it takes exactly a minute. Currently, my internet is having issues so maybe it’s because of that?
@thymikee from the JDK docs:
So it seems we will need to read the output continuously using I/O stream classes. This article may be the solution.