不确定为什么nodemon不起作用,尝试了所有解决方案

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

我已经在全球范围内安装了很多次nodemon,但是当我尝试运行它时,它不起作用。这是我收到的错误:

nodemon : The term 'nodemon' is not recognized as the name of a cmdlet, 
or if a path was included, verify that the path is correct and try again.    
At line:1 char:1
+ nodemon server.js
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (nodemon:String) [], CommandN  
   otFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我不明白为什么我在全局安装了nodemon后却无法使用它。我在 VSCode 终端中收到此错误,但在 cmd.exe 中收到此错误:

'nodemon' is not recognized as an internal or external command,
operable program or batch file.

我尝试从终端和命令提示符全局安装它。我还尝试删除node_modules和package-lock.json,并通过执行

npm install
重新安装它们。我不明白为什么会发生这种情况,也不知道该怎么办。

npm npm-install nodemon
3个回答
1
投票

使用

npx nodemon
,你的操作系统的环境变量可能已损坏,并且不会链接到 npm 全局包的安装位置。


0
投票

您的 npm 该模块不支持或与 Nodemon 不兼容,所以 尝试使用

npx

而不是

npm


0
投票

有趣的是,在 RHEL8.9 和 NodeJS v12.22.0 下,我使用 npm 来启动客户端和服务器实例。 npm 有一个名为 stop 的操作符,但每次都会因缺少脚本错误而失败。例如,根据您的博客,npx 确实可以与 npx stop 服务器正常工作。然而,nodemon 仍然驻留在内存中,并且端口仍然为 nodeman 启用。

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