> easy solution here would be to disable global installs
I think that's not optimal. Having package being installed "globally" (as in available on your PATH) is nice. You can install `yarn` by doing `npm install --global yarn`.
The trouble is how people setup their node/npm installation. Instead of having global packages setup under the home directory, people use the default which requires root access.
Instead, default installation should be in user-accessible place and running npm with sudo should be exiting without doing anything.
> The trouble is how people setup their node/npm installation. Instead of having global packages setup under the home directory, people use the default which requires root access.
No, like you say in your next sentence the trouble is that it's default. This is NPM's fault, not the user.
I don't get what is the issue on requiring a "global" installation to be added to $PATH, a lot of other tools ask for that during installation and it's by far the safest way to do it.
I basically want what you mentioned later but also available to other users.
Home folder installation only works when you A) only want to install for a user B) the user you run under exists on disk and has a home folder and C) the user can be setup to perform updates.
A lot of the time I run tools that will run as a service. The user it runs under might not have a home folder, probably not even a login or shell. I still need access to the tool installed as root and as normal user for maintenance.
So ideally, I add the path into /etc/profile and install the stuff into /usr/local/node/bin where it is perfectly isolated from the rest of the system.
I think you're saying the same thing. Later in his comment, he mentions installing "global" stuff to `/usr/local/node/bin` or something like that, which is easy to add to your PATH (and can be scripted / documented to be easy to set up). Essentially do what homebrew does, which never seems to run into problems and IIRC completely refuses to run as root nowadays.
I think that's not optimal. Having package being installed "globally" (as in available on your PATH) is nice. You can install `yarn` by doing `npm install --global yarn`.
The trouble is how people setup their node/npm installation. Instead of having global packages setup under the home directory, people use the default which requires root access.
Instead, default installation should be in user-accessible place and running npm with sudo should be exiting without doing anything.