According to Dan Dascalescu, Sindre Sorhus's guide is overkill.
Quoting archived version of Michael Bethencourt's guide (whose domain has expired at the time of writing):
The Right Way™ to do global npm install without sudo
[…]
Step 1: Configure NPM
npm config set prefix ~/.localNow NPM will install your global executables to
~/.local/bin, and the libraries to~/.local/lib/node_modules/Step 2: Add
~/.local/binto your pathIf you haven't already, open up the conf file of your favorite shell (such as
~/.bashrcfor Bash), and add in:PATH=~/.local/bin/:$PATHThat's it. You're done.
[…]
Don't forget to source ~/.bashrc (or restart the terminal).