nodesource / ansible-nodejs-role

Ansible Role for Node.js Binary Install
MIT License
131 stars 47 forks source link

Have to use sudo with npm -g #12

Open pajtai opened 9 years ago

pajtai commented 9 years ago

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