Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why sudo is bad for user cli tools and how to work around permission errors #10

Open
sindresorhus opened this issue Nov 17, 2013 · 6 comments

Comments

@sindresorhus
Copy link
Owner

Need to have this guide so I can link to it from sudo-block.

Or as @kevva said it:

how to not sudo your way out

@Rowno
Copy link

Rowno commented Nov 17, 2013

If it helps, here's how I globally install NPM packages without using sudo.

export NPM_CONFIG_PREFIX='~/.npm-packages'
export PATH="$NPM_CONFIG_PREFIX/bin:$PATH"
export MANPATH="$NPM_CONFIG_PREFIX/share/man:$MANPATH"
export NODE_PATH="$NPM_CONFIG_PREFIX/lib/node_modules:$NODE_PATH"

@sindresorhus
Copy link
Owner Author

Thanks.

npm config set prefix ~/npm and export PATH="~/npm/bin:$PATH" should be enough though.

@mathiasbynens
Copy link

This is also a common issue for the default Ruby on OS X. (By default, you need sudo to install gems.)

@Rowno
Copy link

Rowno commented Nov 19, 2013

Same with Ruby on Ubuntu.

@drewdrewthis
Copy link

Works great!

@lesterzone
Copy link

Why not install Nodejs with something like nvm ? It will install Node to ~/ and you no longer need to worry about global packages and their permissions.
I'm using it since I need to work with more than one Node version. It allows me to re-install packages from a previous version to a new one with a single command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants