Emfile error running nodemon - node.js

Can't seem to get nodemon up and running.
It works when using just node (node app.js) but when using nodemon (nodemon app.js) the following Emfile error is returned:
20 Nov 12:26:33 - [nodemon] v0.7.10
20 Nov 12:26:33 - [nodemon] to restart at any time, enter `rs`
20 Nov 12:26:33 - [nodemon] watching: /home/ramzi/ST/swaggertrack
20 Nov 12:26:33 - [nodemon] starting `node app.js`
connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 80
mongo is connected
EMFILE: Watching too many files.
EMFILE: Watching too many files.
EMFILE: Watching too many files.
EMFILE: Watching too many files.
Has anyone got any thoughts?
Thanks.

If you update to nodemon#1.0.12 (currently latest) it will warn out if there's too many files being watched (i.e. > 25,000 files - a rough arbitrary number I chose). If you don't get that warning, it's possible it's your script.
Happy to help debug (assuming you're on the latest version) at http://github.com/remy/nodemon/issues/new

Related

Unable to launch nodemon environment

I'm trying to start my server with nodemon, but it crashes with the following output.
The error ERROR: Unrecognized environment. Aborting. seems quite rare, from a Google search.
Ran the same code in Windows 10 and a WSL2 Ubuntu set up. Both had the same results. The server does start for my coworker for some reason, though.
user#LAPTOP:~/myproject$ npm run start:dev
> myproject#0.0.0 start:dev /home/user/myproject
> nodemon
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src/**/*
[nodemon] watching extensions: ts,html
[nodemon] starting `./node_modules/.bin/ts-node -r tsconfig-paths/register ./src`
[2021-03-23T04:11:42.704Z] ERROR: Unrecognized environment. Aborting.
[nodemon] app crashed - waiting for file changes before starting...
^C
user#LAPTOP:~/myproject$ npm -v
6.14.11
user#LAPTOP:~/myproject$ node -v
v15.12.0
This is a bug with my sequelize code
The issue came from trying to access the sequelize.js database before connecting to it.
Moving my Model.findAll() statement to after the app has launched has fixed the issue.

Trouble with nodemon: The server keeps restarting everytime I make change in the file, without executing the code

I am just getting started with node. I have installed the nodemon using the command npm install -g nodemon now whenever I start my server using nodemon server.js it starts fine but as I make some changes to the code it just keeps on restarting the server which doesn't execute the code in the file, so my progress is not saved.
Ansh#LAPTOP-7QQ43AM7 MINGW64 /f/files/atom/Web Development/my-express-server
$ nodemon server.js
[nodemon] 1.19.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Server has started on port 3000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
Instead of starting the server again after restarting, it just stays in the restarting process

Error: EADDRINUSE on Mac - even though nothing is using the port?

Alexs-MacBook-Pro:build alexnordhausen$ gulp server:start
[21:11:22] Using gulpfile ~/Documents/Kanvasroom_Support/kanvasroom/build/gulpfile.js
[21:11:22] Starting 'env:dev'...
Application loaded using the "development" environment configuration
[21:11:22] Finished 'env:dev' after 6.25 ms
[21:11:22] Starting 'server:start'...
[21:11:22] Finished 'server:start' after 1.95 ms
[21:11:22] [nodemon] 1.11.0
[21:11:22] [nodemon] to restart at any time, enter `rs`
[21:11:22] [nodemon] watching: *.*
[21:11:22] [nodemon] starting `node --debug=5858 --trace-warnings server.js`
Server started, be sure the user content server is also running with gulp user-content
Live-build the client with gulp web:dist
Debugger listening on 127.0.0.1:5858
[Busy] Launching SocketCluster
Error: listen EADDRINUSE 127.0.0.1:5858
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at Agent.Server._listen2 (net.js:1262:14)
at listen (net.js:1298:10)
at doListening (net.js:1397:7)
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
There aren't any ghost processes running... this was working just fine until I did a fresh npm install of the whole project. Thoughts?
As per the logs, you are using clustering. You might be trying to listen from each child process on same port, which will throw error after when second child process got launched.
I can see in your log:
Your master server started on 127.0.0.1:5858.
Then SocketCluster try to starting on 127.0.0.1:5858
So if you one server is already 5858 port, Then how can other server use 5858 ?
So plese change the port for solving the issue.
This error comes when more then two app using a single portno.
Use this command
1) `netstat -tulpn` (Commans for show all the process on server)
2) then kill the process with the process number. like kill 2043

How do you debug nodejs projects?

For the past 16 hours or so, I've been trying to get a MEAN stack project working on my computer.
I started with the Yeoman angular-fullstack project. But that was giving me all kinds of errors so I just gave up on it.
Then I followed some tutorials which helped me get started but didn't cover a ot of my questions.
Then I found mean.io which offers a full boilerplate MEAN stack project, which I followed the instructions to set up. Unfortunately, when I try to run it, I get all kinds of errors again :-(
The worst part about is, that it says NOTHING about what/where is causing the error.
Can someone help me figure it out? Please :-)
The latest error I'm getting is when I run grunt.
C:\Users\Imray\projects Practice\meanIO\meanApp>grunt
Running "hook" task
>> Starting hooked tasks.
Running "clean:0" (clean) task
>> 0 paths cleaned.
Running "jshint:all" (jshint) task
>> 42 files lint free.
Running "csslint:src" (csslint) task
>> 5 files lint free.
Running "concurrent:tasks" (concurrent) task
Running "watch" task
Waiting...
Running "nodemon:dev" (nodemon) task
[nodemon] v1.2.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node --debug server.js`
debugger listening on port 5858
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE
at errnoException (net.js:904:11)
at Server._listen2 (net.js:1042:14)
at listen (net.js:1064:10)
at Server.listen (net.js:1138:5)
at ExpressEngine.beginBootstrap (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\lib\core_modules\server\E
xpressEngine.js:123:14)
at Meanio.serveWithDb (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\lib\core_modules\server\index.js:14
:10)
at Consumer.Dependable.runAction (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-depend
able\index.js:72:22)
at Consumer.Dependable.fire (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependable\
index.js:69:53)
at Consumer.onResolved (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependable\index
.js:119:8)
at Consumer.Dependable.resolve (C:\Users\Imray\projects Practice\meanIO\meanApp\node_modules\meanio\node_modules\lazy-dependab
le\index.js:55:10)
[nodemon] app crashed - waiting for file changes before starting...
According to your output you have Error: listen EADDRINUSE.
It means that you already have running process on this port.
Try to investigate which process uses this port by typing:
sudo lsof -n -i4TCP:$PORT_NUMBER | grep LISTEN
Kill that process and restart your application.
If you need that process, change your application port.
EADDRINUSE is a low level system error, that usually means there's something else running on the port number you're using. Try using a different port.
EDIT: Note that it may not just be the actual server who's port is invalid. It looks like your deployment script creates a debugger, and possibly other services that listen on various ports, so they might need to be changed instead.
The problem went away after I restarted my computer. Not sure why, but I'll take it.

Running node.js w/ supervisor in win8

I'm trying to get my node server running w/ supervisor. I had it working in Windows 7, but now it keeps failing. Here's the output:
"C:\Program Files\nodejs\node.exe" C:\Users\Mark\AppData\Roaming\npm\node_modules\supervisor\lib\cli-wrapper.js --no-restart-on error server.js
DEBUG: Running node-supervisor with
CreateProcessW: The system cannot find the file specified.
DEBUG: program 'server.js'
DEBUG: --watch '.'
DEBUG: --ignore 'undefined'
DEBUG: --extensions 'node|js'
DEBUG: --exec 'node'
DEBUG: Starting child process with 'node server.js'
DEBUG: Watching directory 'D:\Websites\MyProject' for changes.
DEBUG: Program node server.js exited with code 127
This guy suggested trying nodemon instead, but the result is more or less the same:
"C:\Program Files\nodejs\node.exe" C:\Users\Mark\AppData\Roaming\npm\node_modules\nodemon\nodemon.js server.js
26 Jan 22:23:10 - [nodemon] v0.7.1
26 Jan 22:23:10 - [nodemon] watching: D:\Websites\MyProject
26 Jan 22:23:10 - CreateProcessW: The system cannot find the file specified.
[nodemon] starting `node server.js`
26 Jan 22:23:10 - [nodemon] app crashed - waiting for file changes before starting...
However, if I run "vanilla" node.js, it starts up fine:
"C:\Program Files\nodejs\node.exe" server.js
Listening on http://localhost:8081
What might be the problem? Is it the server.js file it can't find? Why wouldn't it be able to find it?
Rebooted Windows, problem went away. It starts up fine now. Probably just needed to restart either Windows or my IDE to refresh some file paths :-)

Resources