NPM 无法解决依赖关系

时间:2021-02-17 06:33:55

标签: npm

我有一个包(@polkadot/api),它依赖于其他一些包(@polkadot/keyring、@polkadot/util-crypto 和 @polkadot/wasm-crpyto)。我需要要求每个包。

如果我安装了 3 个瞬态依赖项,npm 会给我这样的错误:

<GridColumn HeaderText="Action" TextAlign="TextAlign.Center" Width="95">
            <Template>
              <SfDropDownList TItem="ActionDDLVM" Value="@((context as ActionDDLVM).Id)" TValue="string" PopupHeight="100px" Placeholder="Action" DataSource="@LstAction">
                       <DropDownListEvents TValue="string" TItem="ActionDDLVM" OnValueSelect="OnSelect" ValueChange="ValueChange"></DropDownListEvents>
                   <DropDownListFieldSettings Text="Text" Value="Id"> 
                     </DropDownListFieldSettings>
              /SfDropDownList>
             </Template>
</GridColumn>
    
public void OnSelect(SelectEventArgs<ActionDDLVM> Args)
{
  
}
public void ValueChange(ChangeEventArgs<string, ActionDDLVM> Args)
{
 
}

如果我删除了@polkadot/keyring(例如),我会收到这样的错误:

Multiple instances of @polkadot/keyring detected, ensure that there is only one package in your dependency tree.
        5.6.3   /home/clay/projects/saito-lite/node_modules/@polkadot/keyring
        5.6.3   /home/clay/projects/saito-lite/node_modules/@polkadot/api/node_modules/@polkadot/keyring
Multiple instances of @polkadot/wasm-crypto detected, ensure that there is only one package in your dependency tree.
        3.2.3   /home/clay/projects/saito-lite/node_modules/@polkadot/wasm-crypto
        3.2.3   /home/clay/projects/saito-lite/node_modules/@polkadot/api/node_modules/@polkadot/wasm-crypto
Multiple instances of @polkadot/util-crypto detected, ensure that there is only one package in your dependency tree.
        5.6.3   /home/clay/projects/saito-lite/node_modules/@polkadot/util-crypto
        5.6.3   /home/clay/projects/saito-lite/node_modules/@polkadot/api/node_modules/@polkadot/util-crypto

有人可以告诉我如何告诉 npm 解决这些依赖关系吗?我想我可以使用别名并在我的 node_modules 中保留这些瞬态依赖项中的每一个(实际上是 4 个),但是当版本匹配时这似乎几乎没有必要,我只需要每个版本的一个版本。

我觉得 NPM 是这里的傻瓜,但我是吗?这不应该“正常工作”吗?

1 个答案:

答案 0 :(得分:0)

嗯,不是总是这样,只要你在 SO 上写了一个问题,你就会在一分钟后找到答案吗?

事实证明,“npm dedupe”似乎解决了我的问题。

我暂时将问题留在这里,因为我进行了大量搜索,但找不到与此完全相同的任何其他问题。我也认为有讨论什么是处理这个问题的正确方法的空间,polkadot 的人是否可以更好地处理这个问题。