不灭的焱

加密类型:SHA/AES/RSA下载Go
复合类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel)、接口(interface)、数组(array)、结构体(struct) Go类型+零值nil
引用类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel) Go引用

作者:AlbertWen  添加时间:2026-07-17 15:46:58  修改时间:2026-11-22 17:49:58  分类:03.运维管理  编辑

目录

这是因为你在 PowerShell 中执行 npm 时,PowerShell 优先调用了:

D:\www\nodejs\nodejs\npm.ps1

但系统当前的 PowerShell 执行策略禁止运行 .ps1 脚本,因此报错。Node.js 和 npm 本身通常没有安装问题。

解决方案:修改永久策略

在 PowerShell 中执行:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

出现确认提示时输入:

Y

然后重新测试:

npm --version
node --version

CurrentUser 只影响当前 Windows 用户,一般不需要管理员权限;RemoteSigned 允许本地脚本运行,但从互联网下载的脚本需要有效签名,是开发电脑上比较折中的设置。修改会立即生效。(Microsoft Learn)