以后不会在优快云上写博客资源了,感觉太难用了,欢迎关注我的私人网站,https://schuffel.github.io/

1

你已经执行了三步 Git URL 替换规则,但输出中有一个关键问题: ```bash git config --get-regexp urlS ``` → 注意:**命令拼错了!是 `urlS` 而不是 `url`** 这导致你没有看到完整的配置结果。 你应该使用: ```bash git config --get-regexp url ``` (结尾是 `url`,不是 `urlS`) --- ### ✅ 修正后查看真实配置 运行: ```bash git config --global --get-regexp url ``` 或(去掉 `--global` 查看全局): ```bash git config --get-regexp url ``` 你会得到类似: ``` url.https://github.com/.insteadof git@github.com: url.https://github.com/.insteadof ssh://git@github.com/ url.https://gitclone.com/github.com/.insteadof https://github.com/ ``` 但现在我们不确定是否真的设置了第一条:`git@github.com:` → HTTPS --- ## 🔍 关键点:必须包含这一条! > ❌ 如果缺少: ```bash url.https://github.com/.insteadOf git@github.com: ``` > 那么像 `git@github.com:dmapper/dom-to-image.git` 这种格式的依赖就不会被重! 而很多 npm 包正是用这种简方式引用 Git 仓库。 --- ## ✅ 立即修复步骤(请逐行执行) ### 1. 先清理所有旧规则(避免冲突) ```bash git config --global --unset-all url."https://github.com/".insteadOf git config --global --unset-all url."https://gitclone.com/github.com/".insteadOf ``` ### 2. **重新设置三条核心规则(顺序很重要)** ```bash # 规则1: git@github.com:user/repo → https://github.com/user/repo git config --global url."https://github.com/".insteadOf "git@github.com:" # 规则2: ssh://git@github.com/user/repo → https://github.com/user/repo git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" # 规则3: https://github.com/user/repo → https://gitclone.com/github.com/user/repo git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/" ``` --- ### 3. 正确验证配置 ```bash git config --global --get-regexp url ``` 你应该看到: ``` url.https://github.com/.insteadof git@github.com: url.https://github.com/.insteadof ssh://git@github.com/ url.https://gitclone.com/github.com/.insteadof https://github.com/ ``` ✅ 三条都有,顺序无所谓,内容正确就行。 --- ### 4. 测试替换是否生效 #### 方法一:直接测试克隆 ```bash git ls-remote https://github.com/dmapper/dom-to-image.git ``` 👉 它会自动变成: ``` https://gitclone.com/github.com/dmapper/dom-to-image.git ``` 如果返回 commit 列表 → 成功! #### 方法二:开启调试日志,看实际请求地址 ```bash GIT_CURL_VERBOSE=1 git ls-remote https://github.com/dmapper/dom-to-image.git ``` 你会在输出中看到: ``` * Trying 104.21.58.188:443... * Connected to gitclone.com (104.21.58.188) port 443 ``` 🎯 表示流量确实走的是镜像站! --- ### 5. 清理缓存并重试安装 ```bash # 删除 npm 缓存中的 git 克隆临时文件 rm -rf /home/gapinyc/.npm/_cacache/tmp/git-clone* # 删除项目依赖 rm -rf node_modules package-lock.json # 设置国内镜像加速普通包 npm config set registry https://registry.npmmirror.com # 开始安装 npm install ``` --- ## 🚨 常见陷阱提醒 | 错误 | 后果 | |------|------| | 没有设置 `git@github.com:` → HTTPS | NPM 直接尝试 SSH,报 `Permission denied (publickey)` | | 多个镜像规则共存(如 ghproxy + kgithub + gitclone) | 行为不可预测,可能命中错误镜像 | | 忘记清理 `.npm/_cacache/tmp/git-clone*` | npm 使用旧缓存失败重试 | --- ## ✅ 推荐终极方案:切换到 Yarn + resolutions(一劳永逸) 即使你现在能修好 Git,**仍建议永久移除 Git 依赖**。 ### 修改 `superset-frontend/package.json` ```json { "dependencies": { "dom-to-image-more": "^3.2.0" }, "resolutions": { "dom-to-image": "npm:dom-to-image-more@^3.2.0" } } ``` 然后: ```bash npm install -g yarn yarn config set registry https://registry.npmmirror.com rm -rf node_modules package-lock.json yarn install ``` ✅ 不再依赖 GitHub,构建稳定、速度快。 --- ## ✅ 总结:你现在要做的就是 ```bash # 1. 清理旧规则 git config --global --unset-all url."https://github.com/".insteadOf git config --global --unset-all url."https://gitclone.com/github.com/".insteadOf # 2. 设置三条规则 git config --global url."https://github.com/".insteadOf "git@github.com:" git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" git config --global url."https://gitclone.com/github.com/".insteadOf "https://github.com/" # 3. 验证(注意拼!) git config --global --get-regexp url # 4. 测试 git ls-remote https://github.com/dmapper/dom-to-image.git # 5. 清理并安装 rm -rf /home/gapinyc/.npm/_cacache/tmp/git-clone* node_modules package-lock.json npm config set registry https://registry.npmmirror.com npm install ``` ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值