为什么 npm install 说我有未满足的依赖项? [英] Why does npm install say I have unmet dependencies?

查看:28
本文介绍了为什么 npm install 说我有未满足的依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个节点包.当我从包根目录运行 npm install 时,它会安装很多东西,但随后会打印出几条错误消息,如下所示:

I have a node package. When I run npm install from the package root, it installs a bunch of things, but then prints several error messages that look like this:

npm WARN 未满足的依赖项/Users/seanmackesey/google_drive/code/explore/generator/node_modules/findup-sync/node_modules/glob 需要优雅的 fs@'~1.2.0' 但会加载

npm WARN unmet dependency /Users/seanmackesey/google_drive/code/explore/generator/node_modules/findup-sync/node_modules/glob requires graceful-fs@'~1.2.0' but will load

我一定对 npm install 到底做了什么感到困惑.如果它检测到依赖项,它不应该安装它吗?在什么情况下它会给我这样的错误消息,我该如何解决依赖关系?

I must be confused about what exactly npm install does. If it detects a dependency, shouldn't it install it? Under what conditions does it give me error messages like this, and how can I resolve the dependencies?

推荐答案

我相信是因为依赖解析有点破,见https://github.com/npm/npm/issues/1341#issuecomment-20634338

I believe it is because the dependency resolution is a bit broken, see https://github.com/npm/npm/issues/1341#issuecomment-20634338

以下是可能的解决方案:

Following are the possible solution :

  1. 需要手动安装顶层模块,包含未满足的依赖:npm install findup-sync@0.1.2

重新构建您的 package.json.将所有高级模块(作为其他模块的依赖项)放在底部.

Re-structure your package.json. Place all the high-level modules (serves as a dependency for others modules) at the bottom.

重新运行 npm install 命令.

该问题可能是由于超时或其他原因导致 npm 无法下载所有包.

The problem could be caused by npm's failure to download all the package due to timed-out or something else.

注意:您也可以使用 npm install findup-sync@0.1.2 手动安装失败的包.

Note: You can also install the failed packages manually as well using npm install findup-sync@0.1.2.

在运行 npm install 之前,执行以下步骤可能会有所帮助:

Before running npm install, performing the following steps may help:

  • 使用 rm -rf node_modules/
  • 删除 node_modules
  • 运行 npm 缓存清理

为什么有时需要删除 node_modules"?当嵌套模块在 npm install 期间安装失败时,后续的 npm install 将不会检测到那些丢失的嵌套依赖项.

Why 'removing node_modules' sometimes is necessary? When a nested module fails to install during npm install, subsequent npm install won't detect those missing nested dependencies.

如果是这种情况,有时删除那些缺少的嵌套模块的顶级依赖项,然后再次运行 npm install 就足够了.见

If that's the case, sometimes it's sufficient to remove the top-level dependency of those missing nested modules, and running npm install again. See

这篇关于为什么 npm install 说我有未满足的依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆