Nodemon 未重新启动:[nodemon] 由于更改而重新启动

问题描述 投票:0回答:5

Nodemon 未重新启动:[nodemon] 由于更改而重新启动... 如果更改我的代码但不更新我的代码浏览器并显示由于更改循环而重新启动使用,我使用 vs code

问题:

[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node index.js`
server is running at http://127.0.0.1:3000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...

我的代码:

const http = require("http");
const PORT = 3000;
const hostName = "127.0.0.1";
const server = http.createServer((req,res) => {
    res.end("Welco my server  server");
})
server.listen(PORT,hostName, () => {
    console.log(`server is running at http://${hostName}:${PORT}`)
})

package.json:

  "name": "test",
  "version": "1.0.0",
  "description": "test 1",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.17.1",
    "nodemon": "^2.0.9"
  }
}

nodemon --verbos index.js

[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node --verbos index.js`
node: bad option: --verbos
[nodemon] app crashed - waiting for file changes before starting...
node.js nodemon
5个回答
3
投票

这不是一个非常技术性的修复,但我设法让我的

nodemon
再次按预期工作。

首先我运行了

npm cache verify
,它需要很长时间才能运行,所以我使用
npm cache clean --force
清理缓存,必须使用
--force
标志,因为 npm 会告诉你不需要运行
cache clean
命令,如下所示npm 自清理。

然后我刚刚运行了

npm i [email protected] -g
,这是
nodemon version 2
之前的最后一个稳定版本。运行我的
npm run dev
脚本,现在开发人员体验一切都很好。


0
投票

server.listen方法中无需添加主机名。


0
投票

以我为例,在环境“C:\Windows\system32;”中添加系统路径后,仍然出现。但我认识到它似乎在第一次运行 Nodemon 时。尝试存更多钱就能解决问题。


0
投票

尝试以下方法

1 - 卸载并重新安装

2

npm file.js --delay

但真正对我有用的是添加 将我的

environmental variable
的路径添加到
C:\Windows\System32

步骤:

高级系统设置->环境变量->路径->编辑->

C:\Windows\System32


0
投票

我也面临着同样的问题。解决这个问题的方法很简单:直接运行文件,不指定文件名。

例如,如果你的文件名是main.js,不要只使用main.js;相反,请使用文件的完整路径,例如“C:\Users\Desktop\web D\BackEnd\CommonJS\main.js”。

运行命令 nodemon“文件路径” nodemon“c:\Users\Desktop\web D\BackEnd\CommonJS\main.js”

© www.soinside.com 2019 - 2024. All rights reserved.