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

Angular项目无node_modules,npm install遇依赖冲突及私有包404问题

问题分析与解决方案

问题1:@ng-select/ng-select 与 Angular 版本依赖冲突

错误原因

项目使用 Angular 14.x,但 @ng-select/ng-select@8.3.0(由^8.1.1版本范围自动拉取)要求的 peer 依赖为 @angular/common >=13.0.0 <14.0.0,版本不匹配导致依赖解析失败。

解决步骤

修改 package.json 中的 @ng-select/ng-select 版本为支持 Angular 14 的版本,例如 ^10.0.0(该版本适配 Angular 14):

"@ng-select/ng-select": "^10.0.0"

问题2:@ds/* 包 404 找不到

错误原因

@ds/core、@ds/form 等包不在公共 npm 注册表中,属于私有仓库包或本地关联项目包。

解决步骤

根据包的实际来源选择对应方案:

  • 私有 npm 仓库包:
    执行命令配置对应 scope 的私有 registry:
    npm config set @ds:registry https://你的私有仓库地址
    
    或在 package.json 中添加配置:
    "publishConfig": {
      "@ds:registry": "https://你的私有仓库地址"
    }
    
  • 本地关联项目包:
    修改 package.json 中对应包的路径为本地项目路径:
    "@ds/core": "file:../ds-core",
    "@ds/form": "file:../ds-form"
    
  • 废弃/无需使用的包:
    直接从 package.json 的 dependencies 中移除所有 @ds/* 相关条目。

最终执行流程

  1. 保存修改后的 package.json
  2. 执行安装命令:
    npm install --legacy-peer-deps
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 10:17:12