PS C:\Users\Bonnie_Py\Desktop\fullstack js> create-react-app
react-app create-react-app : File C:\Users\Bonnie_Py Dev\AppData\Roaming\npm\create-react-app.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:2
+ create-react-app react-app
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
最佳答案
问题:
当 PowerShell 执行策略不允许我们运行脚本时,就会出现此错误。我在尝试运行 PowerShell 脚本时也发现了同样的错误。
PowerShell - 在此系统上禁用运行脚本
解决方案:
如果您没有管理员权限,请按照以下命令操作 =>“Set-ExecutionPolicy -Scope CurrentUser”。
PowerShell 执行策略默认设置为“受限”。您可以使用 Set-ExecutionPolicy cmdlet 更改 PowerShell 执行策略。要运行外部脚本,请将策略设置为 RemoteSigned。
PS C:\> Set-ExecutionPolicy RemoteSigned
下面是 PowerShell 中四种不同执行策略的列表
受限 – 无法运行任何脚本。
AllSigned – 只能运行由受信任的发布者签名的脚本。
RemoteSigned – 下载的脚本必须由受信任的发布者签名。
无限制 – 可以运行所有 Windows PowerShell 脚本。
您还应该知道:
您可以在 PowerShell 中使用获取当前设置的执行策略。
PS C:\> get-executionpolicy
您可以通过在运行 PowerShell 脚本时添加 -ExecutionPolicy ByPass 来绕过此策略。
c:\> powershell -ExecutionPolicy
关于javascript - 我正在尝试创建 react 应用程序,但一直告诉我未经授权的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60622706/