node-client icon indicating copy to clipboard operation
node-client copied to clipboard

Volta Support?

Open stefanpenner opened this issue 3 years ago • 4 comments

Description

https://volta.sh/ is a fast, reliable cross platform Node.js version manager which is authored in rust, and also managers globally installed node_modules in a unique manner. This helps ensure that those globally installed module are locked to the version of Node.js they are installed it. Overall providing a really great and durable experience to users.

Unfortunately today, neovim's Node.js provider hard-codes support for npm and yarn, which can be seen at: https://github.com/neovim/neovim/blob/0a95549d66df63c06d775fcc329f7b63cbb46b2f/runtime/autoload/provider/node.vim#L50-L83

To be a good citizen volta follows this same pattern, and installs it's globally installed modules at $HOME/.volta/shared, which neovim does not yet currently detect.

Unfortunately, this results in machines managed by volta breaking neovim's Node.js provider. Corresponding Volta Issue

Question

Would there be interest in a pull request, which adds volta as third mechanism of detecting a Node.js provider?

Workaround:

The following has volta behave as if it were yarn, which works with neovim, as it falls down the yarn code-path when detecting the node provider.

volta install yarn 
rm -rf $HOME/.config/yarn/global/
mkdir -p $HOME/.config/yarn/global/
ln -s $HOME/.volta/tools/shared/ $HOME/.config/yarn/global/node_modules

yields a functional node.js provider for neovim.


## Node.js provider (optional)
  - INFO: Node.js: v14.15.0
  - INFO: Neovim node.js host: /Users/spenner/.config/yarn/global//node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.9.0

stefanpenner avatar Nov 11 '20 18:11 stefanpenner

Just let me know, I'll gladly submit a PR if there is interest

stefanpenner avatar Nov 19 '20 16:11 stefanpenner

I would be in favor of supporting Volta!

billyvg avatar Nov 19 '20 16:11 billyvg

There is also an issue on Windows with the various system(['node' ...]) calls made in neovim/runtime/autoload/provider/node.vim and neovim/runtime/autoload/health/provider.vim.

I'm not sure if it is related to Volta or not, but I guess it is because otherwise this would be broken for every node user which would have made the issue a lot more apparent.

But basically in Windows if you call system with an array, like system(['node', '-v']), you get the error node.EXE is not recognized as an internal or external command but if you do system('node -v') then it works as expected.

So I had to go in https://github.com/neovim/neovim/blob/4d5dbea4f402c76de4419977f7f89d3dec572510/runtime/autoload/provider/node.vim#L8 https://github.com/neovim/neovim/blob/4d5dbea4f402c76de4419977f7f89d3dec572510/runtime/autoload/provider/node.vim#L42 https://github.com/neovim/neovim/blob/4d5dbea4f402c76de4419977f7f89d3dec572510/runtime/autoload/health/provider.vim#L667 and so on and replace the arrays with strings to get everything to work properly (that is after setting node_host_prog manually as pointed out in https://github.com/volta-cli/volta/issues/866#issuecomment-730476125)

taylon avatar Feb 20 '21 02:02 taylon

@taylon That very likely is this issue in Volta: https://github.com/volta-cli/volta/issues/939 If node is getting resolved to node.EXE, with the extension in caps, then the current Volta doesn't handle that correctly. We've got a fix merged, so the next release of Volta should fix that and allow node.EXE (or any other weird capitalizations) to work correctly.

charlespierce avatar Feb 20 '21 03:02 charlespierce