带有已发布包的 npm postinstall 脚本

问题描述

我刚刚创建了我的包并将其发布到工件注册表。 这个包有 postinstall 脚本,如果我在包目录中执行 npm i,即使没有 node_modules 目录。

postinstall 脚本中,我使用来自 npm 的 patch-package 来覆盖一些依赖项。

问题是当我用 npm i -s @my/package 在其他项目中安装这个包时。 当 postinstall 脚本正在执行时,它找不到那些包并抛出错误

我尝试在父目录中执行 patch-package,但无论如何都找不到这些包。

知道我能做些什么来解决这个问题吗?

解决方法

为了解决我在 postinstall 脚本安装脚本中为这些包 npm i dep1@0.0.0 dep2@0.0.0 dep3@0.0.0 && rest... 添加的问题。