0

I use Neovim on ubuntu, for coding in Python. My init file is not too complicated and only requires installation of auto-pairs and coc. After installing node, nvm and yarn, everything seems to work fine if I launch Neovim from the Linux Terminal, for example using "sudo nvim apythonfile.py". In this situation, I can edit the file normally, with auto completion working using coc-python. The problem arises when I open a python file simply by double-clicking on it. As I set up Neovim as the default app to launch .py files, Neovim opens the file but this time also displays this error message:

Curent Node.js version v10.19.0 < 14.14.0
Please upgrade your .js

And of course, auto completion does not work here. This is a bit annoying, as I would like to be able to open a python file directly without having to go through the terminal everytime.

I tried to check node --version in the linux terminal, which gave me v14.14.0. So, I have no idea where this v10.19.0 comes from.

Can someone help me solve the problem ?

romainl
  • 186,200
  • 21
  • 280
  • 313
Droidux
  • 146
  • 2
  • 12
  • You should have never started editing files using `sudo` in the first place. What happens if you do `nvim apythonfile.py`, without `sudo`? – Enlico May 10 '23 at 08:15
  • I can do that, it works the same, except that I cant write the file because I don't have the rights for that. – Droidux May 10 '23 at 08:38

2 Answers2

0

Remove Node.js completely from your system as described here: How can I completely uninstall nodejs, npm and node in Ubuntu

And then reinstall Node.js as described here: https://github.com/nodesource/distributions#installation-instructions

Mogens
  • 548
  • 1
  • 3
  • 10
  • I uninstalled node and npm, and now without reinstalling it seems to work. I guess I had two versions of node installed. But now I have a new error message, also when opening a file by double-clicking on it, which is: "[coc.nvim]: Uncaught exception: write EPIPE". – Droidux May 10 '23 at 08:55
  • I suggest you uninstall node and npm completely. When its running now without reinstall, then you haven't uninstalled it completely. Afterwards reinstall as mentioned above. If the new error still appears, then write a new Question for that. – Mogens May 10 '23 at 12:08
0

You can run :checkhealth and it should give you a more detailed description of what's going wrong.

I'd guess it works correctly because your terminal is setting the correct node version (in bashrc or zshrc etc.) and then you're entering neovim. When you double-click a file to open it you circumvent the terminal and open neovim directly, which does not use the node version set by your terminal but by your system.

Try running sudo update-alternatives -a and you can customize which executable to use for every command. You probably have two node versions installed.

James
  • 1