1、查看当前的 npm 镜像设置:
npm config list
2、清空缓存:
npm cache clean --force
3、恢复为默认镜像,此处恢复的镜像用的是 npm 本身,一般国内用户还是建议使用国内镜像
npm config set registry https://registry.npmjs.org/
或者
npm config delete registry
4、推荐设置成用国内镜像
npm config set registry https://registry.npmmirror.com
5、再次运行: npm config list,查看 registry 已经被更改为国内的 npm 公共镜像地址。
6、升级npm到最新版本:
npm install -g npm
7、由于 Windows 11 默认禁止在系统上运行脚本,需要以管理员身份运行 Windows PowerShell,执行以下命令:
set-ExecutionPolicy RemoteSigned