I'm trying to figure out how to set up npm the "best" way for my future Neovim+LunarVim use in Debian stable. I installed the latest stable Neovim from source and I'm in the process of configuring the providers.
LunarVim requires a working npm install -g
and Neovim suggest npm install -g neovim
but, as expected, it does not work out of the box:
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/
LunarVim refers to the npm documentation which gives two options:
Reinstall npm with a node version manager
This is the recommended way, but I don't understand how that would work together with Neovim. The documentation states:
We strongly recommend using a Node version manager like nvm to install Node.js and npm.
…
Node version managers allow you to install and switch between multiple versions of Node.js and npm on your system so you can test your applications on multiple versions of npm to ensure they work for users on different versions.
That's not really my goal. Does that mean that I have to remember to switch to the Neovim npm version every time I want to edit a document? How would installing a package inside Neovim find the right place?
Manually change npm's default directory
This is essentially something like this:
npm config set prefix '~/.npm-global'`
export PATH=~/.npm-global/bin:$PATH
This is something I could feel comfortable with, but I worry that it could affect system-wide usage of Node and npm.
Question
Seeing how I'm not interested in playing with different versions of Node+npm, I do not develop in javascript/Node/whatever, and I want my future Neovim/LunarVim plugins to Just Work™ without having to remember to do X or Y if Z, what would be the recommended way to configure npm in Debian stable for Neovim+LunarVim?
Ideally I would have liked to see something akin to the way python virtual environments are handled in Neovim. There's a g:python3_host_prog
that I've pointed to a local virtual environment. I have not yet understood how to achieve the same thing with npm.