You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.gitignore配置node_modules报错:fatal: cannot use node_modules as an excludesfile

解决Git报错“fatal: cannot use node_modules as an excludesfile”
  • 先检查Git配置里是否误把node_modules设成了排除配置文件:
    运行命令:git config --list | grep excludesfile
    如果输出里出现node_modules,执行对应命令删掉错误配置:
    本地配置:git config --unset core.excludesfile
    全局配置:git config --global --unset core.excludesfile

  • 确认.gitignore文件里的配置正确,应该写:

    node_modules/
    

    (加斜杠明确指定是目录,避免Git把它识别成文件)

  • 如果之前已经把node_modules提交到Git仓库,先清除缓存:
    执行命令:git rm -r --cached node_modules
    然后提交更改:git commit -m "移除缓存中的node_modules目录"

内容的提问来源于stack exchange,提问作者Siddharth Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 06:00:59