My server works well when I run node app.js. However, I am trying to use nodemon to run my server and it doesn't start.
npm start shows the following error:
npm ERR! code ELIFECYCLE
npm ERR! errno 9009
npm ERR! lab11@1.0.0 start: nodemon app.js
npm ERR! Exit status 9009
npm ERR!
npm ERR! Failed at the lab11@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My package.json:
{
"name": "lab11",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.7"
},
"dependencies": {
"express": "^4.17.1"
}
}
My app.js
const express = require('express');
const app = express();
app.use((request, response, next) => {
console.log('Middleware!');
next();
});
app.use((request, response, next) => {
console.log('Otro middleware!');
response.send('¡Hola mundo!');
});
app.listen(3000);
I already tried to:
- Delete node_modules and run npm install
- Delete package-lock.json, run npm cache clean --force and run npm install
- Delete all files and repeat the installation process
- Add npm to path
- Other solutions to this question