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

标签 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

最佳答案

问题:

当 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/

相关文章:

Javascript "Expect ;"int 上

javascript - 即使状态更新也显示之前的内容 5 秒?

arrays - 在 Node.js 中对数组中的相似字符串进行分组

javascript - 我来自 Node 的数据没有绑定(bind)到模板变量

node.js - 下载返回空文件

javascript - JSP Java 脚本验证不起作用

javascript - 传单 map : update marker using navigator. geolocation.watchPosition?

javascript - 在 JS 中读取 pcap.gz 文件

javascript - mongodb nodejs - 转换循环结构

javascript - 如何在io.sockets.on回调中使用io对象?