community.general.pnpm 模块 – 使用 pnpm 管理 node.js 包
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查它是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求。
要在 playbook 中使用它,请指定:community.general.pnpm。
community.general 7.4.0 中的新增功能
概要
- 使用 pnpm 包管理器 管理 node.js 包。 
要求
执行此模块的主机需要以下要求。
- Pnpm 可执行文件位于 - PATH中。
参数
| 参数 | 注释 | 
|---|---|
| node.js 库的别名。 | |
| 以开发模式安装依赖项。 Pnpm 将忽略  选项 
 | |
| pnpm 的可执行文件位置。 默认搜索位置是  | |
| 全局安装 node.js 库。 选项 
 | |
| 安装时使用  选项 
 | |
| 要安装的 node.js 库的名称。 如果没有提供,则安装 package.json 中的所有包。 | |
| 不安装可选包,相当于  选项 
 | |
| 以可选模式安装依赖项。 选项 
 | |
| 安装 node.js 库的基础路径。 | |
| 以生产模式安装依赖项。 Pnpm 将忽略  选项 
 | |
| 命名 node.js 库的安装状态。 如果选择  选项 
 | |
| 要安装的库的版本,采用 semver 格式。 | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全支持 | 可以在  | |
| 支持:不支持 | 处于 diff 模式时,将返回有关已更改内容(或可能需要在  | 
示例
- name: Install "tailwindcss" node.js package.
  community.general.pnpm:
    name: tailwindcss
    path: /app/location
- name: Install "tailwindcss" node.js package on version 3.3.2
  community.general.pnpm:
    name: tailwindcss
    version: 3.3.2
    path: /app/location
- name: Install "tailwindcss" node.js package globally.
  community.general.pnpm:
    name: tailwindcss
    global: true
- name: Install "tailwindcss" node.js package as dev dependency.
  community.general.pnpm:
    name: tailwindcss
    path: /app/location
    dev: true
- name: Install "tailwindcss" node.js package as optional dependency.
  community.general.pnpm:
    name: tailwindcss
    path: /app/location
    optional: true
- name: Install "tailwindcss" node.js package version 0.1.3 as tailwind-1
  community.general.pnpm:
    name: tailwindcss
    alias: tailwind-1
    version: 0.1.3
    path: /app/location
- name: Remove the globally-installed package "tailwindcss".
  community.general.pnpm:
    name: tailwindcss
    global: true
    state: absent
- name: Install packages based on package.json.
  community.general.pnpm:
    path: /app/location
- name: Update all packages in package.json to their latest version.
  community.general.pnpm:
    path: /app/location
    state: latest
