While using nodemon to watch my entire project directory and restart on any file changes during development, it always crashes when a file is changed. I can also force it to happen just by typing rs. Output below:
> ./node_modules/.bin/cross-env NODE_ENV=local nodemon server.js
[nodemon] 1.19.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
(node:95048) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:95048) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Server running on port 8080
(node:95048) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
rs
node:internal/child_process:413
throw errnoException(err, 'spawn');
^
Error: spawn EBADF
at ChildProcess.spawn (node:internal/child_process:413:11)
at spawn (node:child_process:689:9)
at module.exports (/Users/tony/Documents/Node/MILAM/node_modules/pstree.remy/lib/tree.js:8:14)
at main (/Users/tony/Documents/Node/MILAM/node_modules/pstree.remy/lib/index.js:17:12)
at kill (/Users/tony/Documents/Node/MILAM/node_modules/nodemon/lib/monitor/run.js:344:5)
at run.kill (/Users/tony/Documents/Node/MILAM/node_modules/nodemon/lib/monitor/run.js:265:9)
at Bus.<anonymous> (/Users/tony/Documents/Node/MILAM/node_modules/nodemon/lib/monitor/run.js:416:7)
at Bus.emit (node:events:539:35)
at ReadStream.<anonymous> (/Users/tony/Documents/Node/MILAM/node_modules/nodemon/lib/nodemon.js:107:15)
at ReadStream.emit (node:events:539:35) {
errno: -9,
code: 'EBADF',
syscall: 'spawn'
}
Node.js v18.2.0
Related
when i run this command:>npm run dev
restapi#1.0.0 dev
nodemon index.js
[nodemon] 2.0.20
[nodemon] to restart at any time, enter rs
[nodemon] watching path(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node index.js
Error while connecting
db = client.db('Aug_22');
^
TypeError: Cannot read properties of undefined (reading 'db')
trying to connect to live mongodb
It seems that it is not nodemon that makes problem, it is database connection probably.
Check the way you defined your client. Suppose there is some mistake, as error refers...
I wanted a mean starter kit so that I can build my app. Then I got this from github. I just made it setup then made npm install and then made npm start. But it showed me several errors like this
[nodemon] 1.12.1
[0] [nodemon] to restart at any time, enter `rs`
[0] [nodemon] watching: *.*
[0] [nodemon] starting `node server.js`
[0] ✓ App is running at http://localhost:3000 in development mode
[0] Press CTRL-C to stop
[0]
[1] Cannot read property 'config' of null
[1] TypeError: Cannot read property 'config' of null
[1] at Class.run (/Users/Sites/tryouts/mean/node_modules/#angular/cli/tasks/serve.js:51:63)
[1] at check_port_1.checkPort.then.port (/Users/Sites/tryouts/mean/node_modules/#angular/cli/commands/serve.js:123:26)
[1] at <anonymous>
[1] at process._tickCallback (internal/process/next_tick.js:188:7)
So can someone tell me how to make this working? Any help and suggestions will be really appreciable.
I am trying to run nodemon on my local pc.
Even if i just run the command without parameters i get the following error:
events.js:182
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at _errnoException (util.js:1019:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
at onErrorNT (internal/child_process.js:374:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Turning on Verbose mode gives additional info along wiht this error:
[nodemon] Looking in package.json for nodemonConfig
[nodemon] 1.12.1
[nodemon] reading config C:\nodeprojects\myproject\package.json
[nodemon] to restart at any time, enter `rs`
[nodemon] ignoring: .git .nyc_output .sass-cache bower_components coverage C:\nodeprojects\myproject\node_modules/**/*
[nodemon] watching: *.*
[nodemon] watching extensions: js,json
[nodemon] starting `node app.js`
[nodemon] child pid: undefined
[nodemon] exiting
events.js:182
throw er; // Unhandled 'error' event
^
(Note - paths in above error altered to remove my username)
I have tried the basics, restarting my pc, checking if another app is using port 3000 (i dont think it is).
Any help or advice would be appreciated
Nodemon simply starts command "node app.js", if start node ok, it'll track files changes and restart node process.
Your error seems to cause by lack of nodejs configurations.
Try to check node program directory path is included in PATH variable or not.
In the windows pc, there're steps:
Find node install folder, commonly in C:\Program Files\nodejs or C:\Windows\System32\
Check this folder path in PATH variable value.
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
I'm writing my second MEAN app. The first one was build aggregating the components by hand (I was not aware of MEAN) and hosting it at HEROKU; I attempted to use MONGOOSE but gave up due to problems connecting with the database at HEROKU - it worked fine on my MAC. This time around it works on my MAC but I'm still having connection problems; I do not want to jettison MONGOOSE. At this point all I have is the vanilla MEAN app built off its zip file, the zip file downloaded from the MEAN GitHUB repository. See below for the logs I get from HEROKU:
2013-09-10T01:33:28.045816+00:00 heroku[web.1]: Starting process with command `grunt`
2013-09-10T01:33:29.526090+00:00 app[web.1]: Running "jshint:all" (jshint) task
2013-09-10T01:33:29.567534+00:00 app[web.1]: >> 1 file lint free.
2013-09-10T01:33:29.568809+00:00 app[web.1]:
2013-09-10T01:33:29.568809+00:00 app[web.1]: Running "compass:dist" (compass) task
2013-09-10T01:33:29.573055+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574527+00:00 app[web.1]: Warning: Cannot read property 'stdout' of undefined Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]:
2013-09-10T01:33:29.575774+00:00 app[web.1]: Warning: You need to have Ruby and Compass installed and in your system PATH for this task to work. More info: https://github.com/gruntjs/grunt-contrib-compass Used --force, continuing.
2013-09-10T01:33:29.574641+00:00 app[web.1]: Running "compass:dev" (compass) task
2013-09-10T01:33:29.576128+00:00 app[web.1]: Running "concurrent:target" (concurrent) task
2013-09-10T01:33:29.576043+00:00 app[web.1]:
2013-09-10T01:33:30.414023+00:00 app[web.1]: Running "nodemon:dev" (nodemon) task
2013-09-10T01:33:30.511082+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] v0.7.10
2013-09-10T01:33:30.511537+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] to restart at any time, enter `rs`
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/config
2013-09-10T01:33:30.511664+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] watching: /app/app
2013-09-10T01:33:30.536018+00:00 app[web.1]: 10 Sep 01:33:30 - [nodemon] Unable to write to temp directory. If you experience problems with file reloading, ensure /tmp is writable.
2013-09-10T01:33:30.550590+00:00 app[web.1]: debugger listening on port 5858
2013-09-10T01:33:30.578354+00:00 app[web.1]: Running "watch" task
2013-09-10T01:33:30.624330+00:00 app[web.1]: Waiting...10 Sep 01:33:30 - [nodemon] reading ignore list
2013-09-10T01:33:31.152639+00:00 app[web.1]: throw er; // Unhandled 'error' event
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:540:74)
2013-09-10T01:33:31.148967+00:00 app[web.1]: Express app started on port 3000
2013-09-10T01:33:31.152143+00:00 app[web.1]:
2013-09-10T01:33:31.152401+00:00 app[web.1]: events.js:72
2013-09-10T01:33:31.154862+00:00 app[web.1]: Error: failed to connect to [localhost:27017]
2013-09-10T01:33:31.154862+00:00 app[web.1]: at null.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:140:15)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:478:10)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at Socket.EventEmitter.emit (events.js:95:17)
2013-09-10T01:33:31.154862+00:00 app[web.1]: at process._tickCallback (node.js:415:13)
Any comments of suggestions would be much welcome. Thanks in advance.
You need to host MongoDB somewhere. There are a number of MongoDB hosting services, MongoHQ and MongoLab the most popular. I have used MongoHQ with good results although I must admit I haven't stressed my system. You can sign up for the free trial (I think you get 512MB), once you have done that, replace your connection string with (you will get all the details when signing up):
'mongodb://username:password#domain:port/dbName'