首页 > 解决方案 > nodemon 显示正在重新启动服务器,但在对文件进行更改时无法正常工作

问题描述

我正在使用该nodemon软件包,但它没有重新启动服务器。它只显示“由于更改而重新启动”。但在 youtube 视频中,我看到它之后显示“服务器运行”状态。

就我而言,这没有显示出来。它只是显示“由于更改而重新启动”,当我在浏览器中查看时,我的工作也没有更新。

我阅读了很多相关的堆栈溢出问题,但没有一个对我有帮助......在我的项目中本地安装它们作为 devdependent.noting 也不起作用。

我还尝试更改package.json文件中的脚本标签。

在跑步时,我使用了nodemon, npm start, nodemon app.js, nodemon lib/dev-server.js --delay 1,nodemon -L等等,但没有任何帮助。

==================================================== ================================ 编辑问题:

我正在使用 vs 代码。尝试使用 express 框架运行我的 javascript 代码。我正在使用 git bash 终端。任何基本的 hello world 代码也不能与 nodemon 一起运行。我遵循的步骤: node -v并且npm -v正在我的 bash 终端上工作。我创建了一个基本的 hello world express 应用程序。使用npm init npm install express --save

我附上了这个testApp的github存储库https://github.com/webdevshiv/testApp.git 然后主要问题是关于nodemon ..安装nodemon:,npm install nodemon --save-dev也在nodemon install -g 脚本标签中:"scripts": { "start": "node app.js" }, 运行nodemon的代码:nodemon app.js 在我的终端中运行这是我得到的:(bash:nodemon:找不到命令)

但是node app.js正在工作....然后使用npx nodemon app.js它正在显示-----

([nodemon] 2.0.4 [nodemon] to restart at any time, enterrs[nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,json [nodemon] starting节点 app.js Example app listening at http://localhost:3000 [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes... [nodemon] restarting due to changes.)

您可以在第一次监听端口时清楚地看到,但在下次我进行任何更改时,它会显示重新启动。但没有重新启动..在我发布这个之前,这是nodemon正常使用的情况,但现在nodemon无法正常工作......

我正在附加我的系统环境变量路径:C:\Program Files\MongoDB\Server\4.2\bin;C:\Program Files\Git\cmd; C:\Program Files\nodejs; C:\Program Files\nodejs\node_modules\npm

我正在为我的 vs 代码屏幕截图提供链接https://imgur.com/e6ViUaF https://imgur.com/eWOkG0V

标签: javascriptexpressnpmvisual-studio-codenodemon

解决方案


$npm ls chokidar 

在您安装了 nodemon 的目录中运行上述命令。这对我有用。


推荐阅读