Nodemon 不启动服务器
Nodemon doesn't start the server
我将 nodemon 安装到 devDependencies 并设置脚本 "start" : "nodemon server.js"
。但是,当我执行 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.
我的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"
}
}
我也填了server.js,也试过了,没用。
我的server.js文件
const express = require('express');
const app = express();
const PORT = 5000
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`)
})
文件夹中没有任何文件。我在 SO 中找不到类似的错误。我将nodemon安装为全局并检查了pc中的全局环境。没问题。
有什么问题?
尝试
npm uninstall nodemon
然后
npm install -g nodemon
它应该有效
我将 nodemon 安装到 devDependencies 并设置脚本 "start" : "nodemon server.js"
。但是,当我执行 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.
我的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"
}
}
我也填了server.js,也试过了,没用。
我的server.js文件
const express = require('express');
const app = express();
const PORT = 5000
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`)
})
文件夹中没有任何文件。我在 SO 中找不到类似的错误。我将nodemon安装为全局并检查了pc中的全局环境。没问题。
有什么问题?
尝试
npm uninstall nodemon
然后
npm install -g nodemon
它应该有效