终端无法识别 nodemon 命令

nodemon command not recognized by terminal

我正在尝试使用 nodemon 自动重新加载服务器。我已将其安装在本地并将开始设置为

nodemon app.js 使用代码:

"scripts": { "start": "nodemon app.js" }

第一次 运行 还好,但在关闭系统一次并重新打开我的项目后,它似乎不再 运行 正常了。现在每次我使用命令 nodemon app.js 时它都会抛出一个错误。

错误行是:

nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我能采取的最佳解决方案是:

 npm install -D nodemon // install as a dev dependency

 npm start // run script start