ansible-nodejs-role icon indicating copy to clipboard operation
ansible-nodejs-role copied to clipboard

Have to use sudo with npm -g

Open pajtai opened this issue 9 years ago • 0 comments

This causes issues with some npms, e.g. bower.

To get around it I added the following to the task:

- name: Set place for global npms
  shell: npm config set prefix '/home/{{ node_user }}/.npm-packages'
  sudo: no

- name: Add it to your paths
  shell: echo 'export PATH="$PATH:$HOME/.npm-packages/bin"' >> /home/{{ node_user }}/.zshrc

I didn't do a pull request because I wasn't sure how to inorporate the node_user and .zshrc vs .bashrc etc.... but the above fixes the issue and lets you use npm -g without sudo for node_user

pajtai avatar May 27 '15 22:05 pajtai