勒纳。是否有仅在 root 中安装 devDependency 的命令?

Lerna. Is there a command to install devDependency only in root?

根据this comment

Indeed, devDependencies in the root package.json can be used in all packages in the monorepo. This is generally used to co-locate test-related deps and config (jest, eslint, etc).

A couple caveats:

This only works for non-CLI devDependencies. If you need to run a CLI from a child package, that CLI needs to be in that package's devDependencies. (transpiling, flowcopy, etc) All dependencies for a given child package still need to be listed in that child's package.json. (obvious, perhaps? just clarifying)

我看到根目录下的devDependency可以用于所有包。但是,我看不到仅在 root 中安装 devDependency 的明显方法。是否有这样的命令,或者我应该简单地使用 npm/yarn -D install 来执行此操作? (或者手动修改package.json)

如果您使用 Yarn Workspaces,您可以提升根目录中的共享依赖项 node_modules。要在根工作区中安装依赖项,请使用 -W 标志。

yarn add jest --dev -W

正如您所提到的,这些现在可以在任何包中使用。

Source