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

Angular 7中npm run build因@types/lodash-es不兼容失败求解决方案

解决方案

1. 降级类型定义包到兼容版本

你的问题源于高版本@types/lodash和@types/lodash-es使用了TypeScript 3.2.4不支持的类型(如PropertyName、ObjectIterator),需安装与当前TS版本、lodash版本匹配的类型包:

执行卸载与重装命令:

npm uninstall @types/lodash @types/lodash-es
npm install @types/lodash@4.14.182 @types/lodash-es@4.17.6 --save-dev

2. 确认依赖配置

检查package.json的devDependencies,确保版本匹配:

"@types/lodash": "4.14.182",
"@types/lodash-es": "4.17.6",
"typescript": "3.2.4",
"lodash": "4.17.11",
"lodash-es": "4.17.11"

3. 清理缓存并重新构建

执行以下命令清理缓存,避免残留依赖影响:

npm cache clean --force
rm -rf node_modules package-lock.json
npm install
npm run build

备选方案

若上述版本仍存在问题,可尝试更低兼容版本:

  • @types/lodash@4.14.161
  • @types/lodash-es@4.17.3

内容的提问来源于stack exchange,提问作者Desu Sri Meghana

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 02:22:39