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 可执行文件存在于 PATH 中。

参数

参数

注释

别名

字符串

node.js 库的别名。

dev

布尔值

在开发模式下安装依赖项。

Pnpm 将忽略 package.json 中的任何常规依赖项。

选择

  • false ← (默认)

  • true

可执行文件

路径

pnpm 的可执行文件位置。

默认搜索位置是 PATH,如果未设置,则失败。

全局

布尔值

全局安装 node.js 库。

选择

  • false ← (默认)

  • true

ignore_scripts

布尔值

安装时使用 --ignore-scripts 标志。

选择

  • false ← (默认)

  • true

name

字符串

要安装的 node.js 库的名称。

如果未提供,则安装 package.json 中的所有包。

no_optional

布尔值

不安装可选包,等同于 --no-optional

选择

  • false ← (默认)

  • true

optional

布尔值

在可选模式下安装依赖项。

选择

  • false ← (默认)

  • true

路径

路径

安装 node.js 库的基本路径。

production

布尔值

在生产模式下安装依赖项。

Pnpm 将忽略 package.json 中 devDependencies 下的任何依赖项。

选择

  • false ← (默认)

  • true

state

字符串

已命名 node.js 库的安装状态。

如果选择 absent,则必须提供 name 选项。

选择

  • "present" ← (默认)

  • "absent"

  • "latest"

version

字符串

要安装的库的版本,采用 semver 格式。

属性

属性

支持

描述

check_mode

支持: 完整

可以在 check_mode 中运行并返回已更改状态预测,而无需修改目标。

diff_mode

支持:

当处于 diff 模式时,将返回有关已更改内容(或在 check_mode 中可能需要更改的内容)的详细信息。

示例

- 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

作者

  • Aritra Sen (@aretrosen)

  • Chris Hoffman (@chrishoffman),NPM Ansible 模块的创建者