ENOSPC Error in create-react-app - create-react-app

create-react-app error
I get this error message when I run yarn start from my terminal... I've tried sudo killall node and many other process to clear the i-node yet no success.
I have also downgraded my create-react-app version to version 1.5.1 and yet I still have these errors...
Please can anyone help out?

You're most likely hitting the Unix limit of how many files a process can watch.
The following command should help:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

By default linux machine puts some limit on number of programs inotify program can watch/monitor.
On running the react development server, the create-react-app ask the inotify program to monitor more files than its limit. Babel and webpack in the creat-react-app are using chokidar to monitor files which in turn is using inotify program to monitor them, hence this crosses the limit of inotify program.
By running the following command the limit of inotify program is increased and issue is solved.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

i faced the same issue twice...
first time i tried deleting whole node modules using
rm -rf ./node_modules
and installed it again (npm install) and it worked.
BUT, second time it did not.
this time i tried cleaning the unused dependencies from npm modules using,
npm clean-install
and it started the server again.
as it removes the unused dependencies thus decreasing the number of files to watch in a single process.

Related

YARN START gives no space left on device error

OS : UBUNTU 18.04
I created a simple create-react-app project then fired up a server using yarn start. 30% of the times it works fine but 70% of the times I get the following error.
Starting the development server...
events.js:167
throw er; // Unhandled 'error' event
^
Error: ENOSPC: no space left on device, watch '/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/public'
at FSWatcher.start (internal/fs/watchers.js:164:26)
at Object.watch (fs.js:1232:11)
at createFsWatchInstance (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:232:14)
at FSWatcher.NodeFsHandler._handleDir (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:414:19)
at FSWatcher.<anonymous> (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:462:19)
at FSWatcher.<anonymous> (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:467:16)
at FSReqWrap.oncomplete (fs.js:155:5)
Emitted 'error' event at:
at FSWatcher._handleError (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/index.js:260:10)
at createFsWatchInstance (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:39:5)
at setFsWatchListener (/media/prameshbajra/pramesh/Code/learning-react-redux/shopping-cart/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[... lines matching original stack trace ...]
at FSReqWrap.oncomplete (fs.js:155:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm clueless on how this error comes up. I have literally nothing stored on my laptop and around 90% Harddisk is free. The working directory has nearly 200+ GB free space. I also tried starting the project by copying the entire project into different locations(different drives too) but none worked. Also, tried npm start but that too did not work.
Try removing your node_modules folder, then using NPM to install ('npm i') and run ('npm run start'), instead of Yarn.
I received the same error, preventing me from running my Node project using Yarn. I tried Node v10.10.0 and v8.12.0.
Removing my node_modules folder and reinstalling with Yarn did not help.
I had a similar issue. Solved it by increasing the number of inotify watches. using assistance here:
https://github.com/parcel-bundler/parcel/issues/1427
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers
By using:
sudo sysctl fs.inotify.max_user_watches=999999999
and persisted using:
echo fs.inotify.max_user_watches=999999999 | sudo tee -a /etc/sysctl.conf
sudo sysctl --system
You need to check your Node.js version.
As documentation say You’ll need to have Node >= 6 on your local development machine

Watchman crawl failed. Retrying once with node crawler

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 --no-pretty get-sockname
returned with exit code=1, signal=null, stderr=
2018-03-23T11:33:13,360: [0x7fff9755f3c0] the owner of
/usr/local/var/run/watchman/root-state is uid 501 and doesn't match
your euid 0
Testing with jest:
Step 1:
watchman watch-del-all
Step 2:
watchman shutdown-server
You're running watchman as root but the state dir, which may contain trigger definitions and thus allow spawning arbitrary commands, is not owned by root. This is a security issue and thus watchman is refusing to start.
The safest way to resolve this is to remove the state dir by running:
rm -rf /usr/local/var/run/watchman/root-state
I'd recommend that you avoid running tools that wish to use watchman using sudo to avoid this happening again.
As Jodie suggested above I tried the below and it worked well, for the benefit of others mentioning below steps which I tried in my mac to fix this issue
First, Kill all the server running and close your terminal.
Go to 'System preferences' -> 'Security & Privacy' -> privacy tab
Scroll down and click 'Full Disk Access'
Make sure you checked on 'Terminal' and 'Watchman'.
Now relaunch terminal and simply try running again it works!!
-June 8 2022
Giving Full Disk Access to all terminals or where you're getting started your server, is fixed the error.
Also, it would be good to give access (Files and Folders) to VSC.
Here are the steps to do it!
Open System Preferences
Find Security & Privacy option and open it
Give Full Disk Access to your terminals, Xcode and VSC.
Happy Hacking!!!
I had a real issue with this one but finally found the answer.
Here's a screenshot of the post that helped me.
https://github.com/facebook/watchman/issues/751#issuecomment-542300670
The whole forum has multiple different solutions which I hadn't actually tried, but this one is the solution that worked for me! Hope this helps.
watchman watch-del-all && rm -f yarn.lock && rm -rf node_modules && yarn && yarn start -- --reset-cache
I solved this, on linux by using the following commands on terminal.
$ echo 256 | sudo tee -a /proc/sys/fs/inotify/max_user_instances
$ echo 32768 | sudo tee -a /proc/sys/fs/inotify/max_queued_events
$ echo 65536 | sudo tee -a /proc/sys/fs/inotify/max_user_watches
$ pkill node
Then:
$ npm start
or
$ expo start (if you are using expo)
Step 1: $ npm cache clean --force
Step 2: Delete node_modules: $ rm -rf node_modules
Step 3: npm install
Step 4? (Optional): yarn start / npm start
This worked for me. Hopes it works for you too.
On a Mac, remove all watches and associated triggers of running process, then shutdown the service. See screenshot below:
Put your project in a shared folder (ie, Macintosh HD/Users/Shared. I kept getting operation denied on the Desktop, because of further protection policies, even though Full Disk Access was granted.
To solve this issue on my end, i had to stop the other node instance running on my other terminal. Just make sure you don't have another node running on your machine.
check for .watchmanconfig and add this {}.
Inside the file .watchmanconfig
{}
Simple as that just try it.
Watchman config file
I set my .watchconfig file to be extra permissible:
Add this code to your .watchmanconfig file
{
"ignore_dirs": [],
"fsevents_latency": 0.5,
"fsevents_try_resync": true
}
Use sudo command to run watchman.
sudo npm run test
This problem arose because you might be running watchman as root.

npm 3.10.10 install socket hang up error

I am using Node 6.10.1 and npm 3.10.10 on a Dell XPS 15 running Ubuntu 16.04 with Kernel 4.13.0.0-36-generic.
I am behind a corporate proxy which is configured through cntlm.
When I run an npm install -d on a project It works from a short time, and after a while I get Error: socket hang up.
I have found numerous questions about my problem but no solution seemed to work.
Here is an extract of a npm config list :
; cli configs
user-agent = "npm/3.10.10 node/v6.10.1 linux x64"
; userconfig /home/msb/.npmrc
https-proxy = "http://localhost:3128/"
registry = "http://urlTocorporateRegistryWhichWorksOnOtherComputers"
strict-ssl = false
; node bin location = /home/msb/.nvm/versions/node/v6.10.1/bin/node
; cwd = /home/msb
; HOME = /home/msb
; "npm config ls -l" to show all defaults.
I cannot change the registry since we are using some internal modules, and I have to keep the current versions of node/npm.
I have already tried :
Using the proxy directly in npm config rather than through cntlm
Limiting my upload/download capabilities with trickle through the command trickle -s -d 100 -u 100 npm install -d
Another indication : It works on Windows, and I have a collegue running Ubuntu 17.04 on a slower pc and it works for him. We think my machine might be a bit too brutal when requesting the registry. Does anyone know a way to slow npm requests ?
It used to work through yarn but some new developments have forced me to go back to npm.
Has anyone encountered and corrected this problem ?
Thanks for your help.
I experimented the same problem, with no apparent reason, on Ubuntu 18.04.
I finally used docker with bind mounts to solve it. The steps are the following:
Create a dockerfile with the following elements (you can also directly run with the used image if you don't need to configure a proxy like me)
FROM node:6.10.1
ENV HTTPS_PROXY "http://yourproxy:yourport/"
# Different RUN commands to configure npm and git corporate proxy
WORKDIR /home/root/
Build the image (from the dockerfile's folder): docker image build -f npm-installer/Dockerfile -t custom-npm-installer .
Go inside the project folder where you would normally run npm install
Run the following command to run the container interactively: docker container run -it --network host -v </host/path/to/pj>:/home/root/pj-to-install --name custom-npm-installer custom-npm-installer bash
You can now run the npm install command from the container. Careful however, you'll then need to use chmod on the node_modules folder recursively since the container uses root by default.
Another thing, if you're using node-sass, it is most of the time compiled on the fly when npm installing, and matches your OS current version/architecture. So if your linux distribution is not exactly the same than the container's you might need to recompile node-sass on your host after running npm install on the container. No worries though, node-sass will give you the command to run the moment you launch your application.

npm WARN tar EINVAL after WSL Fall Creators Update

Issue:
I just updated my WSL installation after installing the Fall Creators Update and now when I run npm i I get the following warnings from npm I get probably 2-20 of these warnings from random packages each time I install, it's never consistent. Sometimes it even works, no warnings. I thought that this might be okay, but when I run my project npm run dev I get all sorts of errors. It seems to me that the packages aren't installing correctly. But on the occasion when it doesn't show warnings the application runs as expected. I tested with some random projects from GitHub and same issue.
Versions:
NPM Version: 5.5.1
NodeJS Version: 8.9.0
Other Factors: ZSH
ERROR:
npm WARN tar EINVAL: invalid argument, open '/mnt/c/Users/Me/Documents/project/node_modules/.staging/parse-json-07a114c7/index.js'
npm WARN tar EINVAL: invalid argument, open '/mnt/c/Users/Me/Documents/Project/node_modules/.staging/esrecurse-fe2bc2eb/package.json'
Notes:
Tried a fresh install of WSL, same issue
can install globally without issue, only seems to fail in the /mnt/** path.
Can confirm it works in the Linux folders, successful installation in home directory, but breaks on /mnt/**
EDIT: After much troubleshooting I decided to run without ZSH and switching back to using bash.exe instead of the suggested wsl.exe. First install worked. Testing further.
The issue was in fact with the Fall Creators Update. Many optimizations were made and it seems that something to do with symlinking mounted drives had issues. See all the technical conversation here
There are two solutions, first and recommended, the WSL team has already fixed and the fix is in Insiders Build 17035. This fix requires going to Settings -> Insiders -> Selecting "get Active Builds" and then "Fast Ring". Only do this if you are experienced in dealing with occasional breaks as it is essentially beta software.
Fix number two and recommended if you can't update or don't feel comfortable with Insiders Builds is to add this to your .bashrc file:
if ! mount | grep -q "C: on /mnt/c type drvfs (rw,noatime,fallback=1)"; then
echo "== Remount of C: drive required =="
pushd ~ > /dev/null
sudo umount /mnt/c
sudo mount -t drvfs -o noatime,fallback=1 C: /mnt/c
popd > /dev/null
fi
The .bashrc solution does remove many performance gains however so only do if really necessary.

React Native - npm start doesn't start

I'm trying to work with React Native in Fedora 26, and I have followed the facebook tutorial until then.
Everything was going very well, until I try to start the application
with npm
npm start
And receive this error:
> cardbook#0.1.0 start $HOME/cardbook
> react-native-scripts start
9:31:54 AM: Starting packager...
***ERROR STARTING PACKAGER***
Starting React Native packager...
Scanning 770 folders for symlinks in $HOME/cardbook/node_modules (19ms)
Loading dependency graph.
Running packager on port 19001.
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=1507206724: inotify-add-watch($HOME/cardbook/node_modules/react-native-maps/lib/android/lib/build/tmp/expandedArchives/classes.jar_6745ow7srqaaq6vs8k7dkn33k/com/google/android/gms/common/data) -> 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.
Additional Information:
watchman version: 4.9.0
npm version: 3.10.10
Could any pure and kind-hearted soul help me?
I'm running my application right now on my phone. I followed an heuristic approach, trying to resolve the problem quickly, then there is a great lack of information. Anyway I solved it like that:
First I uninstalled watchman:
$ sudo make uninstall
So with yarn (note that I didn't use npm, which still doesn't work), I received the following tips:
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.
Obviously I followed the instructions:
sudo sysctl -w fs.inotify.max_user_instances=1024
sudo sysctl -w fs.inotify.max_user_watches=12288
And received my QR-code with succes.
Just type following commands to fix it if you don't wanna install Watchman
sudo sysctl -w fs.inotify.max_user_instances=1024
sudo sysctl -w fs.inotify.max_user_watches=12288