I am getting this error in my Node.js console:
[nodemon] Internal watch failed: watch /home/dell/Downloads/Adaani5.0
(copy).0/node_modules/engine.io/index.js ENOSPC
For it, I have run two commands after an Internet search:
First:
ps -ef | grep node
sudo kill -9
Second:
echo fs.inotify.max_user_watches=582222 | sudo tee --append
/etc/sysctl.conf&& sudo sysctl -p
And the error persists.
sudo nodemon
Resolved for me. Or login to Root user.
Related
Need to increase watchers in docker image, as it fails on expo publish with the error
[11:39:08] Error: ENOSPC: System limit for number of file watchers reached, watch '/__w/mevris-client-app-products/mevris-client-app-products/node_modules/update-notifier/node_modules/camelcase'
[11:39:08] at FSWatcher.start (internal/fs/watchers.js:165:26)
[11:39:08] at Object.watch (fs.js:1258:11)
[11:39:08] at NodeWatcher.watchdir (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/node_watcher.js:159:22)
[11:39:08] at Walker.<anonymous> (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/common.js:109:31)
[11:39:08] at Walker.emit (events.js:198:13)
[11:39:08] at /__w/mevris-client-app-products/mevris-client-app-products/node_modules/walker/lib/walker.js:69:16
[11:39:08] at go$readdir$cb (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/#react-native-community/cli/node_modules/graceful-fs/graceful-fs.js:187:14)
[11:39:08] at FSReqWrap.args [as oncomplete] (fs.js:140:20)
Added following lines to Dockerfile
RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf && sysctl -p
results in this error when build
sysctl: setting key "fs.inotify.max_user_watches": Read-only file system
I need to use that docker image in Github Actions
Dockerfile
FROM node:10
RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf
RUN echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
RUN echo "fs.inotify.max_queued_events=524288" >> /etc/sysctl.conf
RUN apt-get -qq update && apt-get -qq -y install bzip2
RUN yarn global add #bluebase/cli && bluebase plugins:add #bluebase/cli-expo && bluebase plugins:add #bluebase/cli-web
RUN bluebase plugins
RUN npm i -g expo-cli
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["sh", "/entrypoint.sh"]
I had the same issue running Docker on Mac OSX (not docker-for-mac).
Based on the premise that the sysclt settings are shared with the kernel host,
I fixed the problem doing ssh to the docker-machine (boot2docker) and changing the settings there.
$ docher-machine ssh
$ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -p
From this issues/24 and this issues/628
You need to increase the fs.inotify.max_user_watchesparameter on the
host. For example you can create a configuration file in
/etc/sysctl.d. Example /etc/sysctl.d/crashplan.conf with content:
fs.inotify.max_user_watches = 1048576
You can not change at build time is it will not affect and also it will not allow you during build time.
The workaround is to avoid getting this error, set it during run time in the entrypoint.
FROM node:10.16
# set inotify and start the node application, replace yar with your command
RUN echo "#!/bin/sh \n\
echo "fs.inotify.max_user_watches before update" \n\
cat /etc/sysctl.conf\n\
echo "______________________________________________updating inotify ____________________________________" \n\
echo fs.inotify.max_user_watches=524288 | tee -a /etc/sysctl.conf && sysctl -p \n\
echo "updated value is" \n\
cat /etc/sysctl.conf | grep fs.inotify \n\
exec yarn start:dev \
" >> /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# EXPOSE TARGET PORT
EXPOSE 3001
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
try to echo "fs.inotify.max_user_watches=524288" >> /etc/sysctl.conf
source: whats-wrong-with-my-simple-react-docker-image
PS. Maybe it is a problem of a parent host? Check param on the host befor run docker. This work to me.
I'm running the app with ng serve -o. If I edit styles.scss and hit save then the app live reloads, but editing components (TS or HTML) does not trigger a reload.
No errors show up in in the developer console or in the CLI.
Thoughts?
It happens because of limit of inotify watches and extra files will not be observed, you should increas amount of it.
For Debian, RedHat, or another similar Linux distribution, run:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
For ArchLinux, run:
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
I'm trying to install and run Reaction on mac osx 10.12.15 within below command
npm install -g reaction-cli
reaction init
cd reaction
reaction
Then I got below error I'm just fresh with Reactjs developer so it is simply nervously. And it simply compatible with the package version but how can i solve this problem
=> Started proxy.
=> Started MongoDB.
/Users/sopheak/.meteor/packages/templating-compiler/.1.3.2.1411czp++os+web.browser+web.cordova/plugin.compileTemplatesBatch.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:190
throw error;
^
Error: ENFILE: file table overflow, scandir '/Users/sopheak/Documents/cam/react/reaction/packages/gridfs'
at Error (native)
at Object.fs.readdirSync (fs.js:808:18)
at Object.wrapper (/tools/fs/files.js:1586:35)
at readDirectory (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:338:26)
at Watcher._fireIfDirectoryChanged (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:490:23)
at /Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:747:12
at Array.forEach (native)
at Function._.each._.forEach (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
at Watcher._checkDirectories (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:736:7)
at new Watcher (/Users/sopheak/.meteor/packages/meteor-tool/.1.5.0.15auley++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/fs/watch.js:435:10)
at setupClientWatcher (/tools/runners/run-app.js:800:23)
at [object Object]._.extend._runOnce (/tools/runners/run-app.js:811:7)
at [object Object]._.extend._fiber (/tools/runners/run-app.js:890:28)
at /tools/runners/run-app.js:417:12
This is might be due to the limit on file open files on mac. By default it is set to low. You will need to increase the default size.
$ echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
$ echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -w kern.maxfiles=65536
$ sudo sysctl -w kern.maxfilesperproc=65536
$ ulimit -n 65536
Refer this link for more details.
sudo launchctl limit maxfiles 16384 16384 && ulimit -n 16384
I have a .sh script in my /etc/init-d/forever to configure how forever starts and stops my Node.js app.
I wanted to start forever with the command npm start, so I can trigger my scripts from there. Is this possible?
I tried
sudo forever start --sourceDir /home/my-app -c npm start
but its gets wrong interpreted...
info: Forever processing file: start
error: Cannot start forever
error: script /root/start does not exist.
My script so far is:
NAME=nodeapp
SOUREC_DIR=/home/nodeapp
COMMAND="npm start"
SOURCE_NAME=index.js
USER=root
NODE_ENVIROMENT=production
pidfile=/var/run/$NAME.pid
logfile=/var/log/$NAME.log
forever=forever
start() {
export NODE_ENV=$NODE_ENVIROMENT
echo "Starting $NAME node instance : "
touch $logfile
chown $USER $logfile
touch $pidfile
chown $USER $pidfile
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo -H -u $USER $forever start --pidFile $pidfile -l $logfile -a --sourceDir $SOUREC_DIR -c $COMMAND
RETVAL=$?
}
So I found the answer.
Both --sourceDir and the path parameter after the "npm start"command where necessary:
sudo forever --sourceDir /home/my-app -c "npm start" /
The below command run the forever command in the background with logs in forever.
forever start -c "ng serve " ./
Note the ./
Then you can
forever list
And will be able to see the status and the location of the log file.
info: Forever processes running
data: uid command script forever pid id logfile uptime
data: [0] wOj1 ng serve 29500 24978 /home/user/.forever/wOj1.log 0:0:25:23.326
I am running into an issue. I have deployed my nodejs websocket app to Amazon elastic beanstalk. I am trying to run app as daemon process, that's why I have globally installed pm2 using configfile in ebextension:
container_commands:
01_node_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
02_npm_symlink:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
03_pm2_install:
command: "if [ ! -e /bin/pm2 ]; then npm install pm2 -g; fi"
ignoreErrors: true
As elastic beanstalk start server automatically, to use pm2 I have written start command in my package.js
start:"pm2 start server.js -i 0 --name="hub""
But when elastic beanstalk uses this command to start server it goes in start-stop loop and all cpus is used.
Thanks in advance
That's because pm2 process exits just after it starts the server, so eb run it again. add " && pm2 logs" to the command to keep it on.