【问题标题】:Nodemon is not recognized as an internal command operable program or batch fileNodemon 未被识别为内部命令可运行程序或批处理文件
【发布时间】:2023-04-03 14:50:01
【问题描述】:

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

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

【问题讨论】:

  • 确保nodemon 在您的路径上。你是如何“全球”安装“nodemon”的?你是什​​么意思“它也在C盘显示版本”? “尝试运行项目”是什么意思?
  • globally mean npm install -g nodemon c drive mean when I access user in commond prompt我显示版本意味着它的安装但是当我尝试从E驱动器运行项目时它显示错误
  • 对不起,我仍然无法理解您的意思“当我在命令 prmopt 中访问用户时,我显示的版本意味着它已安装”。请写出简单的陈述性英语句子,用句点分隔。
  • 或显示您正在使用的具体实际命令和具体实际输出。

标签: node.js npm node-modules nodemon


【解决方案1】:

在我的 Windows 中,这是工作:

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

【讨论】:

    【解决方案2】:
    1. 首先试试这个:npm install -g nodemon 如果这在我的情况下不起作用
    2. 试试 yarn add nodemon 会起作用的

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:
        1. 运行:$ npm install -g nodemon

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

        3. package.json 文件更改为:

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

        【讨论】:

          【解决方案5】:

          这是加载错误,在我重新启动系统后完全加载,以便工作

          【讨论】:

            【解决方案6】:

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

            检查后,您可以通过以下方式执行 nodemon:

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

            【讨论】:

              猜你喜欢
              • 2021-08-19
              • 2020-01-28
              • 2015-12-30
              • 2018-07-08
              • 1970-01-01
              • 2014-10-14
              • 2021-03-09
              • 2016-07-29
              相关资源
              最近更新 更多