Error trying to give npm start in react-native project

0

I'm starting to develop apps with react-native, to learn I created a virtual machine running lubuntu and followed the step-by-step installation of prerequisites:

sudo apt-get update

# Instalação do node
sudo apt install build-essential libssl-dev
sudo curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh -o install_nvm.sh
sudo bash install_nvm.sh
source ~/.profile
sudo nvm ls-remote
sudo nvm install 6.11.2

# Instalação Watchman
sudo apt install git
sudo git clone https://github.com/facebook/watchman.git
cd watchman/
sudo git checkout v4.7.0
sudo apt install -y autoconf automake build-essential python-dev
./autogen.sh
./configure
make
sudo make install
sudo apt install npm

# Instalação Flow
sudo npm install -g flow-bin

# Instalação React-native
sudo npm install -g create-react-native-app

# Criar app
create-react-native-app AwesomeProject

But after accessing the AwesomeProject folder and giving npm start the screen hangs and stays only in 17:37:54: Starting packager... and does not advance.

I gave a Ctrl + C to terminate and when trying again this error appeared:

jest-haste-map: Watchman crawl failed. Retrying once with node crawler.
  Usually this happens when watchman isn't running. Create an empty '.watchmanconfig' file in your project's root folder or initialize a git or hg repository in your project.
  Error: Watchman error: A non-recoverable condition has triggered.  Watchman needs your help!
The triggering condition was at timestamp=1503002873: inotify-add-watch(/opt/react-apps/AwesomeProject/node_modules/react-native-maps/lib/android/lib/build/generated/source/r/release/com/facebook/drawee/backends) -> The user limit on the total number of inotify watches was reached; increase the fs.inotify.max_user_watches sysctl
All requests will continue to fail with this message until you resolve
the underlying problem.  You will find more information on fixing this at
https://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch. Make sure watchman is running for this project. See https://facebook.github.io/watchman/docs/troubleshooting.html.

I tried to perform the procedures described in https://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch but did nothing to help

    
asked by anonymous 17.08.2017 / 22:52

2 answers

0

The npm start in this case will only start the packager of React Native. To install your application you have to go to the folder of your project in the terminal and run npm run android . This command will automatically find an emulator (if you have any assets) or an Android device plugged into your machine and install your application.

Once your app is installed and you open it, RN will look up a Packager instance on your local network running. The packager is the one who will provide the JavaScript code you are working on for your application to work.

As for the Watchman problem, try creating a file named .watchmanconfig in your project folder and just type {} inside it.

    
20.08.2017 / 09:58
0

Basically what I did was uninstall watchman. As you installed by make, I imagine that inside the watchman folder, the command below works:

$ sudo make uninstall

Another difference is that I did not use npm , but yarn . Then with yarn start I got the following message:

yarn start
yarn run v1.1.0
$ react-native-scripts start
11:15:08 AM: Unable to start server
  See https://git.io/v5vcn for more information, either install watchman or run the following snippet:
    sudo sysctl -w fs.inotify.max_user_instances=1024
    sudo sysctl -w fs.inotify.max_user_watches=12288
error Command failed with exit code 1.

So I just did what I was told:

sudo sysctl -w fs.inotify.max_user_instances=1024
sudo sysctl -w fs.inotify.max_user_watches=12288

After that, I re-executed yarn start , got my QR-Code, and opened the App by expo.io that worked perfectly.

Note:

  • Practical post on yarn ;
  • Running the App without watchman is not very recommendable, so I suggest if it works without it, try later to understand and solve these issues.
  • 05.10.2017 / 20:17