Corepack 目前如何与 npm 交互?


虽然 Corepack 可以像任何其他包管理器一样轻松支持 npm,但默认情况下当前未启用它的 shim。 这有几个后果:

  • 总是可以在配置为与另一个包管理器一起使用的项目中运行 npm 命令,因为 Corepack 无法拦截它。

  • 虽然 npm"packageManager" 属性中的有效选项,但缺少 shim 将导致使用全局 npm。

While Corepack could easily support npm like any other package manager, its shims aren't currently enabled by default. This has a few consequences:

  • It's always possible to run a npm command within a project configured to be used with another package manager, since Corepack cannot intercept it.

  • While npm is a valid option in the "packageManager" property, the lack of shim will cause the global npm to be used.