【问题标题】:Why does NPM 7.17 not install my peer dependencies为什么 NPM 7.17 不安装我的对等依赖项
【发布时间】:2021-08-28 23:21:44
【问题描述】:

我有一个main 项目,它依赖于本地文件存储中的包package1package1peer依赖快递:

{
  "name": "package1",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "peerDependencies": {
    "express": "^4.17.1"
  }
}

在我做的主项目的文件夹中

npm install ../packages/package1

使用 npm@6.x,它按预期将 package1 作为链接安装在主项目的 node_modules 中。它还给了我一个警告,即缺少对等依赖项 - 正如预期的那样。

现在我使用 npm@7.17 来完成相同的任务。有或没有--legacy-peer-deps 选项。它将 package1 作为链接安装在主项目的 node_modules 中。但它不会在主包中安装对等依赖项,也不会给我一个警告,即缺少对等依赖项。

我希望在主项目中安装一个警告(至少打开-legacy-peer_deps)或express。顺便说一句,它也没有安装在 package1 的 node_modules 中。

有人知道吗?非常感谢。

【问题讨论】:

标签: node.js npm npm-install


【解决方案1】:

同样的事情发生在我身上,根据这个评论 https://stackoverflow.com/a/57915074/473967 看起来 peerDependencies 是用于主机包但不会安装在“插件”包上,所以我们需要添加两次,在依赖项(或 devDependencies)和 peerDependencies 让主机知道。

【讨论】:

    猜你喜欢
    • 2019-12-19
    • 1970-01-01
    • 2016-05-14
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 1970-01-01
    • 2020-06-20
    相关资源
    最近更新 更多