I am running on macOS Sequoia 15.0. I constantly get:
[nodemon] Internal watch failed: UNKNOWN: unknown error, watch.
- I am running nodemon is the root of the project/backend directory Directory structure Error
- This process creates a file named 8080, ? in the root of backend. I have to delete this file before I can restart nodemon.
- I used to be able to run nodemon without any issues on this mac with os 14.x and then suddenly I started getting this error, which will not let me proceed with my project. It may have happened after some minor os 14.x update, I don’t know. However I upgraded to Sequoia just yesterday, hoping that it might solve the problem but there has been no change.
I have looked in forums and have not been able to find a solution. Mostly what I have seen is people running nodemon few directories above where their server.js
or index.js
is located which I understand makes nodemon watch for all changes down directory structure. In my case that is not true, I am running nodemon in the same directory where my server.js
is located, so I assume there is no overhead that way.
Here is my server.js
:
// server.js
require('dotenv').config();
const mongoose = require('./mongoose');
const cors = require('cors');
// Get App
const app = require('./app');
// Get Port
const port = process.env.PORT;
// Enable CORS
app.use(cors());
// Start App if Mongoose is connected
mongoose.connection.on('connected', function () {
try {
app.listen(port, () => {
console.log(`Server is Running on ${port}`);
});
} catch (error) {
console.error(error);
}
});
function graceful() {
mongoose.connection.close(() => {
console.log('MongoDB connection closed.');
process.exit(0);
});
}
process.on('SIGTERM', graceful);
process.on('SIGINT', graceful);
Faruk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.