确定包管理器


【Determining package manager】

稳定性: 1 - 实验性

虽然所有的 Node.js 项目在发布后都应该可以通过所有包管理器安装,但它们的开发团队通常被要求使用某一个特定的包管理器。为了简化这个过程,Node.js 提供了一个名为 Corepack 的工具,它旨在让所有包管理器在你的环境中透明可用——前提是你已经安装了 Node.js。

【While all Node.js projects are expected to be installable by all package managers once published, their development teams are often required to use one specific package manager. To make this process easier, Node.js ships with a tool called Corepack that aims to make all package managers transparently available in your environment - provided you have Node.js installed.】

默认情况下,Corepack 不会强制使用任何特定的包管理器,而是使用与每个 Node.js 版本关联的通用“最后已知良好”版本,但你可以通过在项目的 package.json 中设置 "packageManager" 字段来改善这一体验。

【By default Corepack won't enforce any specific package manager and will use the generic "Last Known Good" versions associated with each Node.js release, but you can improve this experience by setting the "packageManager" field in your project's package.json.】