community.general.npm (8.5.0) — module

Manage node.js packages with npm

Authors: Chris Hoffman (@chrishoffman)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Manage node.js packages with Node Package Manager (npm).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "coffee-script" node.js package.
  community.general.npm:
    name: coffee-script
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "coffee-script" node.js package on version 1.6.1.
  community.general.npm:
    name: coffee-script
    version: '1.6.1'
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "coffee-script" node.js package globally.
  community.general.npm:
    name: coffee-script
    global: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove the globally package "coffee-script".
  community.general.npm:
    name: coffee-script
    global: true
    state: absent
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install "coffee-script" node.js package from custom registry.
  community.general.npm:
    name: coffee-script
    registry: 'http://registry.mysite.com'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install packages based on package.json.
  community.general.npm:
    path: /app/location
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update packages based on package.json to their latest version.
  community.general.npm:
    path: /app/location
    state: latest
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install packages based on package.json using the npm installed with nvm v0.10.1.
  community.general.npm:
    path: /app/location
    executable: /opt/nvm/v0.10.1/bin/npm
    state: present

Inputs

    
ci:
    default: false
    description:
    - Install packages based on package-lock file, same as running C(npm ci).
    type: bool

name:
    description:
    - The name of a node.js library to install.
    required: false
    type: str

path:
    description:
    - The base path where to install the node.js libraries.
    required: false
    type: path

state:
    choices:
    - present
    - absent
    - latest
    default: present
    description:
    - The state of the node.js library.
    required: false
    type: str

global:
    default: false
    description:
    - Install the node.js library globally.
    required: false
    type: bool

version:
    description:
    - The version to be installed.
    required: false
    type: str

registry:
    description:
    - The registry to install modules from.
    required: false
    type: str

executable:
    description:
    - The executable location for npm.
    - This is useful if you are using a version manager, such as nvm.
    required: false
    type: path

production:
    default: false
    description:
    - Install dependencies in production mode, excluding devDependencies.
    required: false
    type: bool

no_optional:
    default: false
    description:
    - Use the C(--no-optional) flag when installing.
    type: bool
    version_added: 2.0.0
    version_added_collection: community.general

unsafe_perm:
    default: false
    description:
    - Use the C(--unsafe-perm) flag when installing.
    type: bool

no_bin_links:
    default: false
    description:
    - Use the C(--no-bin-links) flag when installing.
    type: bool
    version_added: 2.5.0
    version_added_collection: community.general

ignore_scripts:
    default: false
    description:
    - Use the C(--ignore-scripts) flag when installing.
    required: false
    type: bool