0

我已经使用该命令将 npm 包安装到我的 Visual Studio 代码中,向我的终端启动命令 npm install -g create-react-app 但是,我收到错误。在此处输入图像描述

4

1 回答 1

0

这基本上是说 Powershell 的执行策略不允许运行 .ps1 脚本。当您运行 npm install 时,它会尝试执行``

您可以通过两种方式解决此问题:

  1. 使用命令提示符而不是 Powershell
  2. 在 Powershell 中设置脚本执行策略

解决方案 1

我建议你看看这个从 powershell 切换到命令提示符的答案:Visual Studio Code, how to switch from powershell.exe to cmd.exe

解决方案 2

以管理员身份打开powershell,然后在其中输入以下命令
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

这将设置执行策略并允许执行远程签名(第三方)脚本,这意味着可以运行 NPM。

于 2022-01-20T13:51:45.343 回答