---
- name: install nvm
  git:
    repo: https://github.com/creationix/nvm
    dest: "{{ nvm_path }}"
  tags:
  - nvm

- name: install node lts
  command: "bash -ic 'source {{ nvm_path }}/nvm.sh && nvm install --lts'"
  tags:
  - nvm

- name: alias default node
  command: "bash -ic 'source {{ nvm_path }}/nvm.sh && nvm alias default node'"
  tags:
  - nvm

---
- name: install nvm
  git:
    repo: https://github.com/creationix/nvm
    dest: "{{ nvm_path }}"
  tags:
  - nvm

- name: install node lts
  command: "bash -c 'source {{ nvm_path }}/nvm.sh && nvm install --lts && nvm install npm'"
  args:
    creates: "{{ nvm_path }}/versions/node"
  tags:
  - nvm

- name: alias default node
  command: "bash -c 'source {{ nvm_path }}/nvm.sh && nvm alias default node'"
  tags:
  - nvm

- name: find installed npm executable
  command: "bash -c 'source {{ nvm_path }}/nvm.sh && nvm which npm'"
  register: nvm_npm
  tags:
  - nvm

- debug:
    msg: "NPM: {{ nvm_npm }}"

Install npm with nvm and check install path
Install npm with nvm and check install path
