-
Notifications
You must be signed in to change notification settings - Fork 5
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
How to install Node to avoid sudo #4
Comments
As far as anti-patterns go, However, the isolation of not needing to run as root is good for other reasons, too. You can install node and npm to some place that does not require root access to write to. On a Mac, for a single user, Making your own private place to install to and adding it to your
And then there are tools like nvm which automate this and put it in a version-neutral place, so upgrades don't shake it all apart. |
I can't wait until somebody asks this question about Windows; the answer is a nightmare. ;) I personally follow Aria's suggestion (which is also how Homebrew on OS X wants me to have It's true that npm tries to do the right thing when run as root, but it's also true that we've had to fix some bugs because npm didn't quite get things right. Right now, for instance, there's a bug (npm/npm#6548) that will cause a piece of the npm cache's internal machinery to get created with the wrong permissions when you install a git dependency for the first time as root. There have been others, some of which have been addressed relatively recently. I don't see these bugs, because I'm always running npm with regular privileges, so if you do things the same way that the npm developers do, you will have fewer problems as well. 🎉 (This is not actually a good argument.) A little historical contextFrom time to time, somebody will put together a Stack Overflow answer or a blog post showing how you can set up npm to use a subfolder of your home directory as its global location, and while you can do that, it's not the path of least resistance. @isaacs designed npm to put global scripts in upshotSo:
One final recommendation: never run a local install (i.e. |
(It's bad for |
Got this idea from this SO question. Basically use |
@KatieK2 If you need executable scripts in a unix (linux/mac) environment you can |
@darrenderidder A few developers at npm follow that pattern, but I don't, for the same reason that I don't add |
Yeah. I'm torn on it; I add it to mine, but I'm very careful and not on a multi-user system. It's a clever hack, but I'd love to see |
Well, the docs specify |
Yup. Just gotta be careful if you |
Npm scripts already do this! One trick I have been doing lately is to design modules that export
|
@aredridel Agree, although |
@othiym23 not sure if this is the right repo to post this, but really interested in the install/introduction problem. I've been kicking an idea around for a bit now and am curious what other folks think. What if we had a installno.de to point to? Braindump ways to address common problems and scenarios I've dealt with in this area: Somebody told me to install node.js on my macbook
I want to install and manage node with my package manager
I made a node module
|
@imlucas I love the idea. it would be great to have installation instructions available on a rememberable URL like that, since nodejs.org currently just links to compressed build, which is not very beginner-friendly. count me in if you need help. also, maybe opening up a separate issue for this would be a good idea, since this issue is only about avoiding sudo. |
I'm currently working on documenting this for npm, npm/docs.npmjs.com#48 |
What's the best way to install Node to allow packages the permissions they need to install, and to avoid having to
sudo
every package install?It seems like very install process I use results in having to
sudo install whatevs
which is a security anti-pattern. How can I install sanely on my development machine?The text was updated successfully, but these errors were encountered: