Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Please document that it is possible to do "user-global" `npm install`s by setting `prefix` #4536

Closed
ackalker opened this Issue · 3 comments

4 participants

@ackalker

I think I may have mentioned this before on a forum or ML, but here goes again:

Please document the role that prefix plays for npm to decide where to install global modules.
In particular:

$ npm config set prefix ${HOME}/.local

and in ${HOME}/{.profile,.bashrc} # or wherever:

export PATH=${PATH}:${HOME}/.local/bin

This is a much safer way to install 'global' modules.

  • It doesn't require root privileges, sudo rights or whatever.
  • More often than not, there is no need for these modules to be available to all users on the system.

Of course I understand that this will not work for a handful of modules which actually do need elevated privileges to run servers on privileged ports, etc. but these should be installed by root (i.e. no prefix set, defaulting to node's install directory) or in the case of *nix distributions, packaged by a package maintainer anyway.

@smikes

The current documentation for the prefix setting is here - https://github.com/npm/npm/blob/master/doc/misc/npm-config.md#prefix

Does that address your concern about insufficient docs?

Also, if you haven't already tried it, you may wish to check out nvm -- https://github.com/creationix/nvm

We are trying to clean up older npm issues, so if we don't hear back from you within a week, we will close this issue. (Don't worry -- you can always come back again and open a new issue!)

Thanks!

@othiym23
Owner

Closing as abandoned / working by design.

The default prefix is what it is for the simple reason that it's much easier for the vast majority of npm users to get up and running that way. There are many better / safer / more FHS or XDG-compliant ways to install npm, but npm's user base is vast, and most of those users are only installing npm along the way to getting things done, and something that will Just Work for them immediately following install is preferable to something that requires more time spent figuring out how to configure your environment.

@othiym23 othiym23 closed this
@ackalker

Thanks for your comment, yes, I agree that it is well enough documented now, and people who want user-global installation appear to be using it.
My apologies for not answering sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.