我正在尝试创建反应应用程序,但一直告诉我未经授权的访问

Bon*_*ura 0 javascript node.js express

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
Run Code Online (Sandbox Code Playgroud)

小智 6

问题:

\n

当 PowerShell 执行策略不允许我们运行脚本时,就会出现此错误。当尝试运行 PowerShell 脚本时,我也发现了同样的错误。

\n

PowerShell - running scripts is disabled on this system

\n

解决方案:

\n

如果您没有管理员访问权限,请按照以下命令执行\n=>“Set-ExecutionPolicy -Scope CurrentUser”。

\n

PowerShell 执行策略默认设置为“受限”。您可以使用 Set-ExecutionPolicy cmdlet 更改 PowerShell 执行策略。要运行外部脚本,请将策略设置为 RemoteSigned。

\n
PS C:\\> Set-ExecutionPolicy RemoteSigned \n
Run Code Online (Sandbox Code Playgroud)\n

下面是PowerShell中四种不同执行策略的列表

\n

受限\xe2\x80\x93 无法运行脚本。

\n

AllSigned \xe2\x80\x93 只能运行受信任发布者签名的脚本。

\n

RemoteSigned \xe2\x80\x93 下载的脚本必须由受信任的发布者签名。

\n

无限制\xe2\x80\x93 可以运行所有 Windows PowerShell 脚本。

\n

您还应该知道:

\n

您可以使用 PowerShell 中获取当前设置的执行策略。

\n
PS C:\\> get-executionpolicy \n
Run Code Online (Sandbox Code Playgroud)\n

您可以通过在运行 PowerShell 脚本时添加 -ExecutionPolicy ByPass 来绕过此策略。

\n
c:\\> powershell -ExecutionPolicy\n
Run Code Online (Sandbox Code Playgroud)\n