You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行nodemon时提示未被识别,寻求有效解决方案

解决nodemon未被识别的报错问题

报错信息

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.
At line:1 char:1

  • nodemon tut69.js
  • + CategoryInfo          : ObjectNotFound: (nodemon:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    

解决方案

  • 全局安装nodemon
    打开终端执行全局安装命令:

    npm install -g nodemon
    

    注意:Mac/Linux用户可能需要在命令前加sudo获取权限;Windows用户建议用管理员身份打开终端执行。

  • 检查并配置环境变量
    如果已全局安装仍报错,说明npm的全局bin目录未加入系统环境变量:

    • Windows:找到npm全局bin目录(一般是C:\Users\[你的用户名]\AppData\Roaming\npm),手动添加到系统PATH环境变量后,重启终端重试。
    • Mac/Linux:编辑~/.bashrc或~/.zshrc文件,添加以下内容:
      export PATH=$PATH:~/.npm-global/bin
      
      保存后执行source ~/.bashrc(bash终端)或source ~/.zshrc(zsh终端)生效。
  • 本地安装并通过npx运行
    若不想全局安装,可在项目目录下安装本地依赖:

    npm install nodemon --save-dev
    

    然后用npx直接调用:

    npx nodemon tut69.js
    
  • 检查拼写与运行方式
    确认命令拼写正确(是nodemon而非nodmon等);若仅本地安装未全局,直接输入nodemon会报错,必须通过npx或项目的npm scripts调用(可在package.json的scripts里添加"start": "nodemon tut69.js",然后执行npm start)。

内容的提问来源于stack exchange,提问作者Sheel Parikh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 10:07:02