【发布时间】:2021-06-04 06:58:02
【问题描述】:
当我运行 node app.js 时,我的服务器运行良好。但是,我正在尝试使用 nodemon 来运行我的服务器,但它没有启动。
npm start 显示以下错误:
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.
我的 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"
}
}
我的 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);
我已经尝试过:
- 删除 node_modules 并运行 npm install
- 删除 package-lock.json,运行 npm cache clean --force 并运行 npm install
- 删除所有文件并重复安装过程
- 将 npm 添加到路径
- 其他解决方案question
【问题讨论】:
-
请编辑您的问题以包含
app.js的内容 - 当您的脚本出现语法错误时,有时会出现此错误代码。当您尝试使用node app.js运行脚本时会发生什么? -
@esqew 感谢您的推荐。我实现了我的问题。
标签: javascript node.js npm