【问题标题】:npm WARN deprecated lodash@2.4.2: lodash@<3.0.0 is no longer maintainednpm WARN 已弃用 lodash@2.4.2: lodash@<3.0.0 不再维护
【发布时间】:2016-03-02 15:32:52
【问题描述】:

使用 npm 全局安装 grunt-cli 时出现错误。和lodash有关:

npm WARN deprecated lodash@2.4.2:
lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^3.0.0.

这是我正在使用的版本,以及已安装的全局包列表。

节点: v5.1.0

npm: v3.5.0

npm list -g: http://pastebin.com/NuJU3bY0


我尝试全局安装最新版本的 lodash (v3.10.1),但在卸载 grunt-cli 全局包,然后重新安装全局包后,我仍然再次遇到错误。以下是安装日志:

sudo npm install lodash -g
/usr/local/lib
└── lodash@3.10.1

sudo npm install grunt-cli -g
npm WARN deprecated lodash@2.4.2: 
lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^3.0.0.

/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
/usr/local/lib
└─┬ grunt-cli@0.1.13
  ├─┬ findup-sync@0.1.3
  │ ├─┬ glob@3.2.11
  │ │ ├── inherits@2.0.1
  │ │ └─┬ minimatch@0.3.0
  │ │   ├── lru-cache@2.7.3
  │ │   └── sigmund@1.0.1
  │ └── lodash@2.4.2
  ├─┬ nopt@1.0.10
  │ └── abbrev@1.0.7
  └── resolve@0.3.1

npm WARN In grunt-cli@0.1.13 replacing bundled version of nopt with nopt@1.0.10
npm WARN In grunt-cli@0.1.13 replacing bundled version of findup-sync with findup-sync@0.1.3
npm WARN In grunt-cli@0.1.13 replacing bundled version of resolve with resolve@0.3.1
npm WARN In grunt-cli@0.1.13 replacing bundled version of lodash with lodash@2.4.2
npm WARN In grunt-cli@0.1.13 replacing bundled version of glob with glob@3.2.11
npm WARN In grunt-cli@0.1.13 replacing bundled version of inherits with inherits@2.0.1
npm WARN In grunt-cli@0.1.13 replacing bundled version of minimatch with minimatch@0.3.0
npm WARN In grunt-cli@0.1.13 replacing bundled version of sigmund with sigmund@1.0.1
npm WARN In grunt-cli@0.1.13 replacing bundled version of lru-cache with lru-cache@2.7.3
npm WARN In grunt-cli@0.1.13 replacing bundled version of abbrev with abbrev@1.0.7

谁能告诉我我做错了什么,或者如何修复这个错误并获得全新安装的 grunt-cli?

【问题讨论】:

  • 说到lodash,看看你正在使用什么功能,如果你可以使用vanilla JS方式。例如merge 可以替换为Object.assign,在我的情况下,我只使用merge,并删除了lodash,不再出现npm 错误。

标签: node.js gruntjs npm lodash grunt-cli


【解决方案1】:

packagegrunt-cli 依赖于旧版本的 lodash。它不应该影响 grunt 的功能;这只是一个警告信息。

所以,您没有做错任何事情,这不是错误消息,只是警告,并且您安装 grunt-cli 的方式应该可以正常工作。

【讨论】:

  • 只是好奇,怎么解决?在 grunt cli repo 中进行更改?
  • 这个答案可能会让您高枕无忧,但它确实不能解决不需要警告的问题
  • @Sherlock OP 的问题:“我做错了什么?”:什么都没有。 “如何解决这个错误?”:这不是错误,而是警告。 OP 认为他们做错了什么会导致此错误,但这只是一个警告,因为 OP 没有过错。 “修复”错误的唯一解决方案是更新 grunt-cli 以不依赖旧的 lodash 安装。
【解决方案2】:

您可以尝试在控制台中运行此命令:

npm i -g lodash

如果这能解决问题,请告诉我。

【讨论】:

  • 您好,我在安装 Phonegap 时遇到了同样的警告。我试过你的命令行,它显示 lodash@4.3.0 但是当我重新安装 Phonegap 时警告仍然存在。
  • @Pierre 此命令全局安装 lodash,因此您现在安装了两个不同版本的 lodash(全局版本和 Phonegap 版本)。
  • 本地版本总是优先于全局版本。我认为没有其他方法可以通过修复 crunt-cli 本身来解决此问题。
猜你喜欢
  • 2017-12-16
  • 2016-11-17
  • 2022-06-15
  • 1970-01-01
  • 2023-02-08
  • 2022-12-23
  • 2017-09-29
  • 2020-06-22
  • 2020-12-14
相关资源
最近更新 更多