Installing the node_modules

I did the node package managers with nvm

nvm is installed in usr profile directory ~/.nvm
node is installed at ~/.nvm/versions/v10.19.0 , v13.10.0

now i need to install the node modules

I tried with command: bash -c ‘sudo -iu user npm i -g jest’

I am able to install CentOS 7 successfully at the location: ~/.nvm/versions/node/v10.19.0/bin

…/lib/node_modules/jest/bin/

whereas on ubuntu, i getting the error npm command not found. even when i execute the same command at ubuntu terminal.

Can someone throw light to work with Ubuntu -18.04

  • name: Run npm tasks

become: yes
become_user: ‘{{ linux.user.name }}’

command: bash -c ‘sudo -iu {{ linux.user.name }} npm install -g {{ item }}’
loop: “{{ linux.npm_packages }}”

or

  • name: Run npm tasks
    become: yes
    become_user: ‘{{ linux.user.name }}’
    shell: bash -lc ‘npm install -g {{ item }}’
    loop: “{{ linux.npm_packages }}”

Using module file /Library/Python/2.7/site-packages/ansible/modules/commands/command.py

Pipelining is enabled.

EXEC [‘/usr/local/bin/docker’, ‘exec’, ‘-i’, u’ubuntu1804’, u’/bin/sh’, ‘-c’, u’/bin/sh -c 'sudo -H -S -n -u appuser /bin/sh -c '“'”'echo BECOME-SUCCESS-kqeikkibwtmhhlcrdqrmllsljsoxrezm ; /usr/bin/python'“'”' && sleep 0'']

failed: [ubuntu1804] (item=cypress) => {

“ansible_loop_var”: “item”,

“changed”: true,

“cmd”: “bash -lc ‘npm install -g cypress’”,

“delta”: “0:00:00.624562”,

“end”: “2020-04-13 00:05:29.561745”,

“invocation”: {

“module_args”: {

“_raw_params”: “bash -lc ‘npm install -g cypress’”,

“_uses_shell”: true,

“argv”: null,

“chdir”: null,

“creates”: null,

“executable”: null,

“removes”: null,

“stdin”: null,

“stdin_add_newline”: true,

“strip_empty_ends”: true,

“warn”: true

}

},

“item”: “cypress”,

“msg”: “non-zero return code”,

“rc”: 127,

“start”: “2020-04-13 00:05:28.937183”,

“stderr”: “bash: npm: command not found”,

“stderr_lines”: [

“bash: npm: command not found”

],

“stdout”: “”,

“stdout_lines”:

}

META: ran handlers

META: ran handlers

Regards,

Muni