[英]Nodemon doesn't start the server
I installed nodemon to devDependencies and set the script "start": "nodemon server.js"
.我将 nodemon 安装到 devDependencies 并设置脚本
"start": "nodemon server.js"
。 However, when I do npm start
, it throws me this error:但是,当我执行
npm start
,它会抛出这个错误:
Error: Cannot find module 'C:\Users\win10\Desktop\nodemon\bin\nodemon.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! question-answer-rest-api@1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the question-answer-rest-api@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我的 package.json
{
"name": "question-answer-rest-api",
"version": "1.0.0",
"description": "Back end project for practice",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"keywords": [
"Express",
"Nodejs",
"Mongoose",
"Api"
],
"author": "Cihan Özcan",
"license": "MIT",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
I also filled in server.js and tried that way but it didn't work.我还填写了 server.js 并尝试了这种方式,但没有奏效。
My server.js file我的 server.js 文件
const express = require('express');
const app = express();
const PORT = 5000
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`)
})
There are no any file in the folder.文件夹中没有任何文件。 I couldn't find similar error in SO.
我在 SO 中找不到类似的错误。 I installed nodemon as global and checked the global environment in pc.
我将nodemon安装为全局并检查了pc中的全局环境。 There is no problem with it.
没有问题。
What is the problem?问题是什么?
Try尝试
npm uninstall nodemon
Then然后
npm install -g nodemon
It should works它应该有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.