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

Poetry构建因node_modules存在过慢,求彻底忽略该文件夹的方案

解决Poetry构建时彻底忽略node_modules的技巧
  • 精准配置pyproject.toml的排除规则
    不要只写exclude = ["node_modules"],改用递归匹配规则确保覆盖所有子文件和目录:

    [tool.poetry]
    exclude = ["node_modules/**/*"]
    

    这种写法会让Poetry完全跳过对node_modules目录下所有内容的扫描,而非仅在打包环节排除。

  • 用环境变量临时强制排除
    构建时通过环境变量直接指定排除目录,绕过配置文件可能存在的优先级问题:

    POETRY_EXCLUDE="node_modules/**/*" poetry build
    
  • 让Poetry继承.gitignore规则
    既然已在.gitignore里配置了node_modules/,可以让Poetry直接复用该规则,避免重复配置的冲突:

    [tool.poetry]
    include = ["**/*"]
    exclude = []
    [tool.poetry.gitignore]
    inherit = true
    

    配置后Poetry会严格遵循.gitignore的排除逻辑,不再额外扫描已忽略的目录。

  • 临时禁用插件构建
    如果安装了Poetry插件(比如export、publish类插件),部分插件可能会额外遍历目录导致耗时增加,尝试不带插件构建:

    poetry build --no-plugins
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.20 03:31:22