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

Windows 11下nodemon启动失败报错的解决方法咨询

解决nodemon启动时的UnauthorizedAccess错误

这个错误是Windows PowerShell的执行策略限制导致的——默认策略不允许执行未签名的PowerShell脚本,而nodemon全局安装后生成的nodemon.ps1正好属于这类脚本。下面是几种可行的解决办法:

方法1:临时放开当前PowerShell会话的执行策略

  • 右键点击PowerShell,选择「以管理员身份运行」
  • 执行命令:Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  • 按提示输入Y确认,之后当前会话就能正常运行nodemon index.js了

方法2:换用命令提示符(cmd)运行

如果不想修改PowerShell的策略,直接打开cmd,输入nodemon index.js即可——cmd不受PowerShell执行策略的限制

方法3:通过npm脚本启动nodemon

修改你的package.json,在scripts里添加启动脚本:

{
  "name": "gfg-express",
  "version": "1.0.0",
  "description": "How to connect express with mongodb atlas",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon index.js"
  },
  "author": "Greyhat07",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2"
  }
}

之后在终端运行npm start,npm会自动处理脚本的执行权限问题

方法4:用npx直接调用nodemon

在终端(PowerShell或cmd都可以)执行:npx nodemon index.js,npx会直接调用nodemon的核心可执行文件,绕开PowerShell脚本的权限限制

内容的提问来源于stack exchange,提问作者Subhamay Nath

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 14:40:38