解决 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给加入黑名单,那么这个项目估计也就黄了;

相关推荐
飞鸟malred12 小时前
vite+tailwind封装组件库
前端·react.js·npm
好运yoo2 天前
npm install的原理
前端·npm
pzpcxy5202 天前
安装VUE客户端@vue/cli报错警告npm WARN deprecated解决方法 无法将“vue”项识别为 cmdlet、函数
前端·vue.js·npm
醉书生ꦿ℘゜এ2 天前
npm error Cannot read properties of null (reading ‘matches‘)
前端·npm·node.js
Revol_C2 天前
【AI+赋能前端-提效篇】开发一个支持项目打包产物本地调试的小工具,已发布到npm!!
前端·npm·ai编程
空中湖2 天前
‘pnpm‘ 不是内部或外部命令,也不是可运行的程序
npm·node.js
孟孟~3 天前
npm run dev 报错:Error: error:0308010C:digital envelope routines::unsupported
前端·npm·node.js
孟孟~3 天前
npm install 报错:npm error: ...node_modules\deasync npm error command failed
前端·npm·node.js
程序猿小D3 天前
第14节 Node.js 全局对象
linux·前端·npm·node.js·编辑器·vim
Jadon_z4 天前
vue2 项目中 npm run dev 运行98% after emitting CopyPlugin 卡死
前端·npm