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

Angular 8.2升级至9.0失败:执行命令时遇找不到模块错误

Angular升级报错:Cannot find module '../lib/init' 解决办法

执行Angular 8.2到9.0升级时,运行命令NG_DISABLE_VERSION_CHECK=1 npx @angular/cli@8 update @angular/core@8 @angular/cli@8出现Error: Cannot find module '../lib/init'错误,可尝试以下几种解决方案:

  • 清理npx缓存后重试
    执行命令清理缓存:

    npx clear-npx-cache
    

    之后重新运行原升级命令。

  • 指定具体CLI小版本执行
    避免版本拉取的模糊匹配问题,指定8.x的稳定版本:

    NG_DISABLE_VERSION_CHECK=1 npx @angular/cli@8.3.29 update @angular/core@8 @angular/cli@8
    
  • 本地安装对应版本CLI后执行

    1. 先卸载全局可能冲突的CLI(可选):
      npm uninstall -g @angular/cli
      
    2. 本地安装8.x版本CLI:
      npm install @angular/cli@8 --save-dev
      
    3. 使用本地CLI执行升级:
      NG_DISABLE_VERSION_CHECK=1 ng update @angular/core@8 @angular/cli@8
      
  • 清理依赖后重新安装

    1. 删除项目根目录下的node_modules文件夹和package-lock.json文件
    2. 重新安装依赖:
      npm install
      
    3. 再次执行升级命令

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.13 12:50:21