Corepack 如何与 npm 交互?
虽然 Corepack 可以像任何其他包管理器一样支持 npm,但默认情况下不启用它的 shim。 这有几个后果:
-
总是可以在配置为与另一个包管理器一起使用的项目中运行
npm命令,因为 Corepack 无法拦截它。 -
虽然
npm是"packageManager"属性中的有效选项,但缺少 shim 将导致使用全局 npm。
While Corepack could support npm like any other package manager, its shims aren't enabled by default. This has a few consequences:
-
It's always possible to run a
npmcommand within a project configured to be used with another package manager, since Corepack cannot intercept it. -
While
npmis a valid option in the"packageManager"property, the lack of shim will cause the global npm to be used.