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

@nrwl/workspace未安装及sourcemap-codec导出异常问题求助

解决Angular项目中的两个核心错误:@nrwl/workspace未安装与sourcemap-codec导出异常

1. 处理@nrwl/workspace未安装问题

执行以下命令安装依赖(根据你的包管理工具选择):

  • npm:npm install @nrwl/workspace --save-dev
  • yarn:yarn add @nrwl/workspace --dev

如果项目使用Nx框架,需确保@nrwl/workspace版本与项目中Nx版本一致。查看package.json中的nx版本号,安装对应版本:
npm install @nrwl/workspace@<你的Nx版本号> --save-dev

2. 修复sourcemap-codec导出错误

报错是因为sourcemap-codec v2+改用默认导出,而当前Angular compiler-cli依赖旧版本的命名导出。需降级到v1.x版本:

  1. 卸载现有版本:
    npm uninstall sourcemap-codec
    或 yarn:yarn remove sourcemap-codec
  2. 安装兼容版本:
    npm install sourcemap-codec@1.4.8 --save-dev
    或 yarn:yarn add sourcemap-codec@1.4.8 --dev

3. 清理缓存并重新安装依赖(可选但推荐)

如果上述步骤后问题仍存在,执行以下操作:

  • 清理npm缓存:npm cache clean --force
  • 删除依赖目录和锁文件:
    rm -rf node_modules package-lock.json
    npm install
    
    若使用yarn:
    rm -rf node_modules yarn.lock
    yarn install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.18 17:52:10