解决 npm xxx was blocked, reason: xx bad guy, steal env and delete files

问题复现

今天一位朋友说,vue2的老项目安装不老依赖,报错内容如下:

bash 复制代码
npm install      
451 Unavailable For Legal Reasons - GET https://registry.npmmirror.com/vab-count - [UNAVAILABLE_FOR_LEGAL_REASONS] vab-count was blocked, reason: vabjs bad guy, steal env and delete files. (operator: cnpmcore_admin/61f154594ce7cf8f5827edf8)

搜了一下发现 vab-croppers 和 vab-count已经被npm列入了黑名单

问题分析:

package.json 默认走 npm源,但是 被 https://registry.npmmirror.com 禁用了,下载不来, 没有被默认的 https://registry.npmis.org 禁用,就用 npm pack vab-croppers --registry=https://registry.npmjs.org/ 下载源码 ,再将源码部署到 git , 替换package.json的引用就行;

还有一种方式就是 将源 指定为 https://registry.npmjs.org 直接下,可惜慢需要梯子;

方案一:替换npm包的地址为git

下载源码:

bash 复制代码
npm pack vab-croppers --registry=https://registry.npmjs.org/
npm pack vab-templates --registry=https://registry.npmjs.org/
npm pack vab-count --registry=https://registry.npmjs.org/

修改package.json 为git地址

bash 复制代码
{

​​​​​​​"vab-count": "git+https://gitee.com/ggbhack/vab-count.git",
"vab-croppers": "git+https://gitee.com/ggbhack/vab-croppers.git",
"vab-templates": "git+https://gitee.com/ggbhack/vab-templates.git",
}

方案二:替换npm的源

https://registry.npmmirror.com 替换为 https://registry.npmjs.org

唠叨一下;为了后续项目正常运行,最好用方式一,做一个备份;就怕这些依赖包,那天也被 npmjs给加入黑名单,那么这个项目估计也就黄了;

相关推荐
sanzk3 天前
Node.js | pnpm下载安装与环境配置
npm
爱宇阳3 天前
npm 常用标签与使用技巧新手教程
前端·npm·node.js
郑板桥303 天前
TypeScript:npm的types、typings、@type的区别
javascript·typescript·npm
@大迁世界3 天前
2025 年该选谁?npm vs yarn vs pnpm
前端·npm·node.js
crary,记忆3 天前
简介NPM 和 NPX
前端·学习·npm·node.js
前端架构师-老李4 天前
npm、yarn、pnpm的对比和优略
前端·npm·node.js·pnpm·yarn
勉灬之4 天前
通过npm run XXX命令生成uniapp的pages.json文件
npm·uni-app·json
duandashuaige7 天前
解决用electron打包Vue工程(Vite)报错electron : Failed to load URL : xxx... with error : ERR _CONNECTION_REFUSED
javascript·typescript·electron·npm·vue·html
weixin_405023378 天前
包资源管理器NPM 使用
前端·npm·node.js
小于小于09128 天前
npx 与 npm 区别
前端·npm·node.js