It looks like you're running the first part of the command (sudo curl http://npmjs.org/install.sh) as root, but then piping it to sh with your regular account permissions. Try splitting it up into two commands: