在安装软件包之前运行脚本,并将 nodeLinker 设置为节点模块

nco*_*hen 7 yarnpkg yarn-v2 yarnpkg-v2

package.json在运行之前,我必须运行一个脚本(来自我的文件) yarn install。该脚本设置私有包的配置。在我的 中.yarnrc.yml,我有nodeLinker: node-modules(并且我想保持这种方式,因为如果删除它,我会收到其他错误)。

问题是当我运行时yarn run myscript出现以下错误:

Usage Error: Couldn't find the node_modules state file - running an install might help (findPackageLocation)

$ yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
Run Code Online (Sandbox Code Playgroud)

但我无法install在脚本之前运行,因为我有一些私有包在安装之前需要该脚本。

我刚刚从 NPM 切换到 Yarn 3.2.0。借助 NPM,我可以在安装软件包之前运行脚本。