Apo*_*ing 4 powershell npm firebase vue.js visual-studio-code
我在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设置。
小智 133
直接删除firebase.ps1文件:
文件 C:\Users\<your account>\AppData\Roaming\npm\firebase.ps1
kmg*_*mgt 19
对于那些使用 VS Code 并收到about_Execution_Policies错误的人。就我而言,使用命令ncu -u(npm-check-updates)。
用CMD试试:
只需再次执行CMD中的命令即可。
如果此方法有效,安全设置可以保持原样。
小智 16
一点说明:当您以管理员身份运行 PowerShell 时,在大多数情况下,您不需要记下路径。只需输入:
Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
然后按“A”,然后按“Enter”
小智 12
此外,值得一提的是,您需要以管理员身份打开 PowerShell,然后像这样更改策略。
PS C:\> Set-ExecutionPolicy RemoteSigned
参考 - 使用 Set-ExecutionPolicy Cmdlet
Sah*_*oru 12
搜索powershell。
右键单击并以管理身份运行。
运行这个简单的命令Set-ExecutionPolicy RemoteSigned。
按A并输入。
转到代码并运行yarn add <YOUR_MODULE>。
按 Enter 键。
现在恭喜它完成了。
小智 6
这可能是由于当前用户具有未定义的 ExecutionPolicy。
你可以试试下面的
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
这是一个Powershell安全策略,要对其进行修复,请运行以下命令
PS C:\> Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
策略越严格,系统就越安全。
你可以改变下RemoteSigned到其他选项,如:Restricted,AllSigned,RemoteSigned,Unrestricted
来源:https : //tecadmin.net/powershell-running-scripts-is-disabled-system/
我在 powershell 中也遇到了这个问题,我使用了以下命令:然后我再次安装了服务包。
Set-ExecutionPolicy -Scope CurrentUser
Run Code Online (Sandbox Code Playgroud)
然后我选择Unrestricted并发出serve命令,它起作用了。
小智 5
我对 npm 没有任何问题,但在 windows 上使用 yarn 也有同样的问题。就我而言,我删除了yarn.ps1 并且对我来说效果很好:
文件路径:
C:\Users\<your account>\AppData\Roaming\npm\yarn.ps1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3923 次 |
| 最近记录: |