Coc.nvim: [coc.nvim] node is not executable (node installed by nvm)

Created on 9 Jun 2019  Â·  16Comments  Â·  Source: neoclide/coc.nvim

Describe the bug

When installed with nvm, node when we first started the shell is a function defined in nvm scripts. So if we use executable to check, the error will be shown as above

Reproduce the bug

# lazy load nvm zsh plugin
NVM_LAZY_LOAD=true
zplugin ice wait"0" lucid
zplugin light lukechilds/zsh-nvm

open the shell, execute nvim, the error above will show up
run which node:

node () {
        unset -f node npm npx yarn nvm > /dev/null 2>&1
        _zsh_nvm_load
        node "$@"
}

run node -v && nvim, the error will no longer show

I think We should change the executable('node') check to something else, because most of node users is using nvm to install node

Most helpful comment

because most of node users is using nvm to install node

I can't agree, since nvm sucks on many cases.

Use let g:coc_node_path = '/path/to/node' when you can't use node in your $PATH.

All 16 comments

because most of node users is using nvm to install node

I can't agree, since nvm sucks on many cases.

Use let g:coc_node_path = '/path/to/node' when you can't use node in your $PATH.

because most of node users is using nvm to install node

I can't agree, since nvm sucks on many cases.

This personal opinion regarding nvm is irrelevant to the true fact mentioned by the OP.

Please reconsider providing a user-friendly feature for solving this annoying issue.

So how do I resolve this? I have just installed neovim and coc.nvim on a fresh ubuntu 16.04 system. Do I have to install nodejs?

just set the variable as suggested. nvm will have the node executable somewhere.

@LukeAI Make node in your $PATH

Cool! Had this same problem after removing the system's node and replacing it by n node installation.

At the end, the problem happened when my i3 shortcuts were launching NVIM with /bin/sh instead of bash. When using sh my custom node's bin location was not in the path, since my export command is in bashrc and sh sources .profile instead.

You can debug it by using echo executable('node') which will return 1 if it exists and is executable, and by using echo $PATH to print the environment variables considered by NVIM context.

As mentioned by people above, setting the path by using let g:coc_node_path = '/path/to/node' works. However, you must use the full path /home/xxx/path/to/node.

I also had the same problem. I'm using Fish shell with nvm (https://github.com/FabioAntunes/fish-nvm)

Luckily, fish-nvm provides nvm_alias_command that creates binaries under /usr/local/bin.

So, what I did was I just executed nvm_alias_command node and coc is working again

My linux pc got corrupted and decided to install ubuntu and had to re-install everything. As I download zsh I encountered this problem. May I ask where can I put this single line?
let g:coc_node_path = '/path/to/node'
do I just put that somewhere in coc.vim or am I wrong.
Screenshot from 2020-03-20 17-36-29

@kirbygit What's the result of which node ?

do I just put that somewhere in coc.vim or am I wrong.

put into your vimrc

ah I see @fannheyward thanks

make it work always: let g:coc_node_path = trim(system('which node'))

make it work always: let g:coc_node_path = trim(system('which node'))

system command would slow down your vim on startup significantly

I did it and I find very little slow down actually but yes I figured it
would be a trade off.

On Tue, Jun 9, 2020 at 5:20 AM Qiming zhao notifications@github.com wrote:

make it work always: let g:coc_node_path = trim(system('which node'))

system command would slow down your vim on startup significantly

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/neoclide/coc.nvim/issues/856#issuecomment-641018691,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AD7WGR6SHEHO6A7ISBLLWT3RVW2BXANCNFSM4HWI3ENA
.

Just add a zsh function to lazy load nvm before starting nvim/vim

nvim () {
    unset -f nvim
    _zsh_nvm_load
    nvim "$@"
}

worked out alright for me

save yourself some pain.
install asdf,

On Fri, Jul 17, 2020 at 8:40 AM Shang Cai notifications@github.com wrote:

Just add a zsh function to lazy load nvm before starting nvim/vim

nvim () {
unset -f nvim
_zsh_nvm_load
nvim "$@"
}

worked out alright for me

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/neoclide/coc.nvim/issues/856#issuecomment-659930094,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AD7WGR23DVEVCG7Y75ET7ITR3756LANCNFSM4HWI3ENA
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhou13 picture zhou13  Â·  3Comments

MaskRay picture MaskRay  Â·  3Comments

skylite21 picture skylite21  Â·  3Comments

MacGuffinLife picture MacGuffinLife  Â·  4Comments

rkulla picture rkulla  Â·  3Comments