React-native: Stuck in "Scanning folders for symlinks in..."

Created on 9 Mar 2018  ·  41Comments  ·  Source: facebook/react-native

Environment

Environment:
  OS: Windows 10
  Node: 9.8.0
  Yarn: Not Found
  npm: 4.6.1
  Watchman: Not Found
  Xcode: N/A
  Android Studio: Version  3.0.0.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.52.0 => 0.52.0

Expected Behavior

When I'm trying to install app to Android Emulator, this problem occurs;

Scanning folders for symlinks in C:\Users\Furkan\AwesomeProject\node_modules (30ms)

Actual Behavior

-npm already running
-System Variables are OK
-CMD (via Administrator)
-Android 5.0.1 (API 21, All SDK components/Extras/Build Tools was installed)
-adb devices;

List of devices attached
emulator-5554   device
PS C:\Users\Furkan\AwesomeProject> react-native run-android --deviceId emulator-5554
Scanning folders for symlinks in C:\Users\Furkan\AwesomeProject\node_modules (30ms)
(and Terminated)

Steps to Reproduce

-run "npm start"
-run ".androidSDK/tools/emulator -avd Nexus6"
-run "react-native run-android" (when Android booted)

Bug Windows Ran Commands Locked 📦Bundler

Most helpful comment

problem seems solved after closing and opening the terminal and running the command

All 41 comments

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest stable release?

Thank you for your contributions.

How to ContributeWhat to Expect from Maintainers

When I ran react-native upgrade command, CMD says me;

Successfully upgraded this project to react-native v0.52.0
PS C:\Users\Furkan\AwesomeProject> react-native -v
react-native-cli: 2.0.1
react-native: 0.52.0

Edit: Same with npm install -g react-native-git-upgrade

Upgraded to 0.55 and still same.

Update: It's works well with ;
Expo's npm start and press a key to open emulator

But react-native run-android not working.

I have the same issue on Ubuntu

Same bug here on Mac. I am glad I found this ticket. I try to debug now why this happens.

I had a similar problem when using Create React Native App. It turned out I simply had to eject before being able to run an Android build.

For me, the root of the issue was in watchman.

I solved it by sudo rm -rf /usr/local/var/run/watchman

https://stackoverflow.com/questions/45477184/built-stuck-at-0-0-while-bundling-index-ios-js/45477185#45477185

me too stuck here

problem seems solved after closing and opening the terminal and running the command

Restarting the terminal worked for me as well. Huh.

for me this worked
init the project (once again)
react-native start (Terminal -> node)
react-native run-android(Treminal -> Powershell)

I was kind of silly, but maybe it will be useful to someone else.. I created two projects as the tutorial suggests:

I tried to run the command react-native run-android on a project created with:
create-react-native-app AwesomeProject -> the specified error happened here

However it is only available if you use the default project created with this command
react-native init AwesomeProject

Check the SDK and and also in environment settings add "C:\Users\\AppData\Local\Android\Sdk\platform-tools" and "C:\Users\\AppData\Local\Android\Sdk\tools" to User Variable. As well add JAVA_HOME and ANDROID_HOME (path) to your system variable

i solve the problem like this

  1. terminal 1 : npm start (wait utiil start)
  2. terminal2 : react-native run-android
npm start
react-native run-android

I don't think that's a solution. :) We may need a reasonable explanation of the cause of this bug.

I created my React-Native application with expo and getting this same error. How about anybody else on expo?

The problem for me was that the Metro Bundler (The window with title 'node "....local-cli\cli.js" start') was open in the background from a previously terminated build.

After I closed that window, the new build process was able to spawn a new Metro Bundler and all proceeded fine from there.

restart vs code and terminal worked. :)

"Restarting" is not a solution. Must have a rational explanation.

Did you install using create-react-native-app AwesomeProject?

@Dentrax
you need to initialize the project first, following this steps
cd C:\Users\Furkan
react-native init AwesomeProject
cd AwesomeProject
react-native run-android

Uhm so it's a process that hangs, basically, right?

OP used npm: 4.6.1, have you tried upgrading to latest (v6 I think)? Does it still happen? Or, as @MichaelPote points out, is actually a Metro Bundler instance being kept alive in the background?

Been getting this error too. Tried reinstalling watchman, restarting terminal, no luck.
I used CRNA to create the project. Funny thing is, this is from my github repo and the project worked before.

In case it helps:

Environment:
  OS: macOS 10.12.6
  Node: 10.1.0
  Yarn: 1.6
  npm: 6.0.1
  Watchman: 4.9
  Xcode: 9.2
  Android Studio: N/A

I do not know why, but there is no explanation in this bug. I think that explanations and details need to be improved. Isn't it? @kelset

i have same issue

What's happening? I got this issue like out of nowhere!?

Has this issue been addressed by any of the developers? It seems to be active and its something that is bothering a lot of users. Can we please get an update / some assistance?

Thanks

I restart my laptop then it works. Still don't know why.

Upgrade the react-native package

react-native upgrade
After doing this
Make sure you are connected to the internet
*
Bcz when you run the app for the first time it will download the gradle dependency

react-native run-android
*This command itself downloads all the gradle dependency

This method 100% works

The issue is simply because of some previous process which wouldn't have been properly terminated before.
for ubuntu just find the process using
sudo lsof -i:8081
terminate the process by
sudo -9 kill <your-process-id>

windows users can try by running cmd as admin then
netstat -ano | findstr :8081
terminate the process by
taskkill /PID <your-process-id> /F

hope this works cheers :)

I have the same problem on Windows 10 and React Native version 0.55.4

+1 this just happened to me on Windows 10.

chrisgrp's answer contained the beauty I needed to fix it. It appears to be related to Metro Bundler getting stuck for unknown reason.

I have good insight into the error after loading a pre-existing project made in iOS onto my Windows PC. I was using React Native on a different PC before, so this Windows 10 machine is kind of semi-baked in terms of it's preparedness for React Native.

I did:

$ yarn install
$ yarn android

and it threw an error about SDK location, which I fixed by defining the path in ./android/local.properties (or alternately, you can define the ANDROID_HOME env variable). That started throwing an SDK licence warning. I fixed that by running the SDK Manager in Android Studio and installing API level 25.

Then, I ran yarn android again without a phone & USB cable hooked up, but the emulator was running in Android Studio. It either failed or I pressed CTRL+C to kill the process.

The next time I ran yarn android, I saw the behaviour described in this thread/issue.

This fixed it for me (remember, Windows only):

$ netstat -ano | findstr :8081
$ taskkill /PID <your-process-id> /F

The question is why did Metro Bundler hang or get stuck? and why can't it unstuck itself when you run yarn android ? The user shouldn't have to care if it's running or not. I might guess it's related to some setup or teardown reference/garbage collection issue.

I tied closing VS Code and reopening it, but that didn't work. I had to run taskkill.

👋 @agm1984 thanks for the detailed explanation!

Have you perhaps tried with any other bundlers (ex. Haul?)?
If there is "hard evidence" that is strictly related to Metro I think an issue in the dedicated repo should be opened so that the Metro team could take a closer look at it.

Follow these steps :
1) sudo netstat -ntlp
tcp6 1 0 :::8081 :::* LISTEN 13398/node
2) sudo kill -9 [port 8081] i.e. sudo kill -9 13398

and then
3) react-native run-android

I had the same issue , And my problem was that the packager was already running (cli.js)

@chrisgrg you are right the same happens on windows :D, maybe you forgot to close another instance of the cli bundler :D

I just reproduced this error again, but this time in Ubuntu.

I usually trigger refreshes in the app by pressing CTRL+S even if I don't change any code. Sometimes I have to press it 2-3 times which brings a risk of red screen of death. But thats ok because you can just press CTRL+S again and it reloads properly.

Long story short, I just did that and it didn't work, so I ran adb shell input keyevent 82 from the terminal and selected 'Reload'. I think the bundler was already dead at this point because my screen was blank white with the green bar at the top "connecting to http://localhost:8081".

That force reload lead to hanging on the symlink scan:

Scanning folders for symlinks in /home/adam/dev/some-app/node_modules (16ms)

I fixed it with npm start, CTRL+C'd out of that and ran react-native run-android and it worked fine. Closing the VS Code instance and reopening it (to kill/reopen terminal) didn't fix it.

npm start did. It absolutely fixed it. After that, I see the commend in here about killing the process on port 8081. I'm sure that would fix it also.

The bundler gets stuck sometimes. If a person wants to reproduce it, just hammer on CTRL+S while hot reload is enabled :) You will surely see some opportunities to fix a stuck bundler.

I would venture a guess that if the bundler is in progress refreshing and you trigger another refresh, you can cause it to implode. It can occur about 50% of the time. The faster you trigger reloads, the higher the chance you will reproduce this or a similar issue.

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\native\AwesomeProject>react-native run-android
Scanning folders for symlinks in C:\native\AwesomeProject\node_modules (89ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat install
Debug)...

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':app'.

    Failed to notify project evaluation listener.
    Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 5s
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html

It looks like it's packager running in the background is what causes this, closing the packager terminal will then correct the problem and restart packager.

This issue has been moved to facebook/metro#377.

Was this page helpful?
0 / 5 - 0 ratings