Nodemon 未被识别为内部命令可运行程序或批处理文件

Nodemon is not recognized as an internal command operable program or batch file

我正在使用 NodeJS,但由于其他一些问题,我再次安装了 Windows。现在我已经全局安装了 nodemon,它还在 C 驱动器中显示版本,但是当我尝试 运行 项目时,它给了我错误:

nodemon is not recognized as an internal command operable program or batch file

确保在当前项目的 package.json 文件中有 nodemon 依赖项。如果您没有在该文件中看到它 运行 npm i nodemon --save

勾选后,您可以通过以下方式执行 nodemon:

  • 运行ning 脚本 nodemon index.js(或您的 js 文件的任何名称)
  • 运行ning 命令 npm run start(尽管您必须使用新脚本 package.json 文件更新脚本 "start": "nodemon index.js"
  • 运行ning 命令 nodemon,但在这种情况下,您的当前项目中也必须有 index.js 文件,因为默认情况下 nodemon 将尝试查找并执行 index.js 文件.

这是加载错误,在我重新启动系统后已完全加载,因此可以正常工作

  1. 运行: $ npm install -g nodemon

  2. 运行: $ npm install --save-dev nodemon

  3. package.json 文件更改为:

"scripts": {
    "serve": "nodemon index.js"
}
  1. 运行: $ npm run serve

我将其安装为“npm install -g nodemon”。 这对我有用。

  1. 首先尝试这个:npm install -g nodemon 如果这对我来说不起作用
  2. 试试 yarn add nodemon 它会起作用

在我的 Windows 中,这是工作:

  1. npm 安装-g nodemon
  2. 打开你想要运行nodemon的文件夹,ex在我的图片中: https://i.stack.imgur.com/fUTnV.jpg
  3. 在终端中写入:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  4. 在终端中写入:nodemon

你写的是install而不是init 运行 npm 安装 nodemon