NPM without sudo
Setting up a couple of Linux systems to work with
FilterBubbler, which is one of
the things
that I’m up to at work now. FilterBubbler is a WebExtension,
and the setup instructions use web-ext,
so I need NPM. In order to keep all the NPM stuff under my own home
directory, but still put the web-ext tool on my $PATH, I
need to make one-line edits to three files.
One line in ~/.npmrc
prefix = ~/.npm
One line in ~/.gitignore
.npm/
One line in ~/.bashrc
export PATH="$PATH:$HOME/.npm/bin"
(My /bashrc has a bunch of export PATH=
lines so that when I add or remove one it’s more likely to get a clean
merge. Because home directory in git.) I think that’s it. Now I can
do
npm install --global web-ext
with no sudo or mess. And when I clone my home directory on another system it will just work.
Based on: HowTo: npm global install without root privileges by Johannes Klose