Error trying to give npm start in React-Native project

Asked

Viewed 1,790 times

0

I’m starting in the development of apps with React-Native, to learn created a virtual machine running Lubuntu and followed the step by step installation of the 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 give the npm start the screen hangs and is only in 17:37:54: Starting packager... and does not advance.

I gave Ctrl+C to quit and while 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 carry out the procedures described in https://facebook.github.io/watchman/docs/troubleshooting.html#poison-inotify-add-watch but nothing helped

  • Have you tried running the'touch . watchmanconfig 'command from the terminal in your project root?

  • I’ll try, but now only Monday

2 answers

0

The npm start then it will only start the packager 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 active ones) or an Android device plugged into your machine and install your application.

Once your app is installed and you open it, the RN will search on your local network an instance of Packager running. Packager is the one who will provide the code Javascript that you’re working for your app to work.

As to the problem of Watchman, try creating a file called .watchmanconfig in your project folder and just type {} within the same.

  • I’ll try the Watchman, but as for the npm start it alone is to generate a QR code that you can read with the app expo (https://expo.io) and so emulate on the phone itself without having to be plugged into the pc, as described here https://facebook.github.io/react-native/docs/getting-started.html

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 I didn’t use the npm, but rather the yarn. So 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 simply did what was recommended:

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

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


Obs.:

  1. Practical post on Yarn;
  2. Running the App without Watchman is not very recommended, so I suggest that if it works without it, try later to understand and solve these issues.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.