pnpm init
创建一个 package.json 文件。
🌐 Create a package.json file.
选项
🌐 Options
--bare
新增于:v10.25.0
🌐 Added in: v10.25.0
创建一个仅包含必填字段的 package.json。
🌐 Creates a package.json with only the required fields.
--init-type <type>
- 默认:模块
- 类型:commonjs、module
设置包的模块系统。
🌐 Set the module system for the package.
--init-package-manager
将项目固定到当前的 pnpm 版本。
🌐 Pin the project to the current pnpm version.
自 v11 起,固定版本被写为 devEngines.packageManager 条目(而不是传统的 packageManager 字段),因此支持版本范围,并且解析后的版本会被记录在 pnpm-lock.yaml 中。
🌐 Since v11, the pin is written as a devEngines.packageManager entry (instead of the legacy packageManager field), so version ranges are supported and the resolved version is captured in pnpm-lock.yaml.
在工作区子包内,此标志无效——devEngines.packageManager 字段仅添加到工作区根的 package.json。
🌐 Inside a workspace subpackage this flag has no effect — the devEngines.packageManager field is only added to the workspace root's package.json.