VSC PowerShell。在 npm 更新包后,无法加载 .ps1,因为在此系统上禁用了运行脚本

新手上路,请多包涵

我在 VSC 中设计网站,PowerShell 是我的默认终端。

在早些时候将网站更新并部署到 firebase 后,系统提示我更新 firebase 工具——我使用 npm 进行了更新。在没有以下错误的情况下,我无法运行/访问任何 firebase 脚本后立即:

firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1

firebase + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

我花了几个小时四处寻找,找不到可靠的答案。许多线程已经有好几年了,我觉得很奇怪,我在过去的一年里直到今天都没有遇到过这个问题。如果我将默认终端设置为 cmd,我仍然可以访问 firebase 脚本。

假设问题与我一直在工作的 firebase-tools 有关,但现在已经更新了 vue.js 并在尝试在 powershell 中运行任何 vue 命令时再次出现错误:

vue : File C:\Users\mada7\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1

vue + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

VSCode Version: Version: 1.37.1 (user setup) Commit: f06011a Date: 2019-08-15T16:17:55.855Z Electron: 4.2.7 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.18362 OS Version: Windows 10 Home Version - 1903 OS build - 18362.295

我一直在阅读并看到许多关于脚本权限的线程,但我没有更改任何内容 - 实际上,PowerShell 脚本一直有效,直到我更新了我的包。同时没有触及其他设置。我不想不必要地更改 PowerShell 设置。

原文由 Aponting 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 668
1 个回答

只需删除 firebase.ps1 文件:

文件 C:\Users\<your account>\AppData\Roaming\npm\firebase.ps1

原文由 Drashyr 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题