pnpm bootstrap Error: Cannot Load \AppData\Roaming\npm\pnpm.ps1 Because Script Execution Is Disabled
This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文
Error message:
pnpm : 无法加载文件 C:\Users\wood\AppData\Roaming\npm\pnpm.ps1,因为在此系统上禁止运行脚本。
有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ pnpm bootstrap
+ ~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Solution:
This error is caused by the Windows execution policy (Execution Policy). By default, Windows blocks PowerShell scripts from untrusted sources.
In this case, pnpm tries to load a script named pnpm.ps1, but its unknown origin causes it to be treated as untrusted. To resolve this, you need to modify the PowerShell execution policy to allow scripts from untrusted sources to run.
Try the following steps:
- Open a PowerShell terminal.
- Run the PowerShell terminal as an administrator.
- Run this command:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
- Enter Y to confirm the execution policy change.
You should now be able to run pnpm bootstrap successfully.
Last updated 2024-01-14
Comments 0