【问题标题】:I'm getting error like this while creating react app我在创建反应应用程序时遇到这样的错误
【发布时间】:2020-04-21 00:38:47
【问题描述】:
-->
create-react-app : File C:\Users\ADMIN\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:1
+ create-react-app demo
【问题讨论】:
标签:
node.js
reactjs
create-react-app
【解决方案2】:
确保从npm 全局删除create-react-app,并使用npx create-react-app {project_name} 生成一个react 应用。
npm uninstall --global create-react-app
npx create-react-app sample
另外,在执行这些操作时,请确保您的 npm 版本在 5.2 之后。
【解决方案3】:
以管理员身份运行 power shell
- Windows 开始
- 搜索“Windows Powershell”
- 右键单击 Windows Powershell
- 点击以管理员身份运行(如果出现,请在“用户帐户控制”中授予)
- 输入
set-executionpolicy remotesigned
- 选择/键入是 [Y]
【解决方案4】:
试试这个命令:npx create-react-app yourappname
【解决方案6】:
只需以 administrator 身份运行 Power shell
然后执行命令:set-executionpolicy remotesigned
【解决方案7】:
出现此错误是因为 Microsoft 为您的安全更改了一些 PowerShell 执行策略。
我们主要可以从两个地方创建 React 应用。
-
命令提示符 - 您可以轻松创建新的 react 项目而不会遇到任何问题。
-
可视化代码中的 Powershell 终端 - 如果您还没有禁用 powershell 的新策略,那么您将面临这样的问题。您需要按照一些步骤禁用这些安全功能。
- 以管理员身份运行 power shell
- 输入 set-executionpolicy remotesigned
- 将有 5 个选项。
- 您需要输入 Y(表示 [Y] 是)并单击 Enter 按钮。
- 现在您可以在可视化代码中创建 React 应用了。
希望它对你有用。
【解决方案8】:
只需在“任务管理器”中停止您的节点服务器,然后启动。之后尝试使用 npx 或 npm 安装。
希望有用。
【解决方案9】:
别担心,我也遇到了这个错误。
当您尝试编写命令 create-react-app 时会出现此错误
当您键入命令 npm install -g create-react-app 时,运行此命令后,您应该重新启动命令提示符或命令 powershell,无论您正在使用什么。
现在重新启动命令提示符后,您可以键入 create-react-app cmd。
【解决方案10】:
如果您是 Windows 操作系统用户,请打开您的 Powershell 并将以下命令粘贴到您的 PowerShell
cmd -> set-executionpolicy remotesigned。