You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS Code终端中成功执行npm create vite@latest命令?

解决PowerShell中npm脚本未签名无法运行的问题

问题说明

在VS Code终端执行npm create vite@latest(注:你输入的命令写成了vital,正确应为vite)时,触发如下错误:

npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded. The file C:\Program Files\nodejs\npm.ps1 is not digitally signed. You cannot
run this script on the current system. For more information about running scripts and setting execution policy, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1

  • npm create vital@latest
  • + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess
    

解决步骤

  • 以管理员身份打开系统自带的PowerShell(不要用VS Code内的终端)
  • 执行命令:Set-ExecutionPolicy RemoteSigned
  • 弹出确认提示时,输入Y并回车
  • 关闭所有PowerShell窗口和VS Code,重新启动VS Code后,在终端执行正确的npm create vite@latest命令

补充说明

RemoteSigned策略允许运行本地脚本,同时要求远程脚本必须经过数字签名,既满足npm的运行需求,也能维持基础安全防护。

内容的提问来源于stack exchange,提问作者SHNS MLCPR

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 03:48:13