community.general.yarn module – Manage Node.js packages with Yarn
Note
This module is part of the community.general collection (version 10.7.5).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: community.general.yarn.
Synopsis
- Manage Node.js packages with the Yarn package manager https://yarnpkg.com/. 
- Note that at the moment, this module only works with Yarn Classic. 
Requirements
The below requirements are needed on the host that executes this module.
- Yarn Classic installed in bin path (typically - /usr/local/bin)
Parameters
| Parameter | Comments | 
|---|---|
| The executable location for yarn. | |
| Install the Node.js library globally. Choices: 
 | |
| Use the  Choices: 
 | |
| The name of a Node.js library to install. If omitted all packages in package.json are installed. To globally install from local Node.js library. Prepend  | |
| The base path where Node.js installs libraries. This is where the  | |
| Install dependencies in production mode. 
 Choices: 
 | |
| The registry to install modules from. | |
| Installation state of the named Node.js library. If  Choices: 
 | |
| The version of the library to be installed. Must be in semver format. If “latest” is desired, use  | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Support: full | Can run in  | |
| Support: none | Will return details on what has changed (or possibly needs changing in  | 
Examples
- name: Install "imagemin" Node.js package.
  community.general.yarn:
    name: imagemin
    path: /app/location
- name: Install "imagemin" Node.js package on version 5.3.1
  community.general.yarn:
    name: imagemin
    version: '5.3.1'
    path: /app/location
- name: Install "imagemin" Node.js package globally.
  community.general.yarn:
    name: imagemin
    global: true
- name: Remove the globally-installed package "imagemin".
  community.general.yarn:
    name: imagemin
    global: true
    state: absent
- name: Install "imagemin" Node.js package from custom registry.
  community.general.yarn:
    name: imagemin
    registry: 'http://registry.mysite.com'
- name: Install packages based on package.json.
  community.general.yarn:
    path: /app/location
- name: Update all packages in package.json to their latest version.
  community.general.yarn:
    path: /app/location
    state: latest
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| Output generated from Yarn. Returned: always Sample:  | 
