Executed these commands:

sudo npm cache clean -f sudo npm install -gn sudo n stable 

node -v shows 4.6.2 but should be at least 8.0.0 or am i wrong?

sudo node -v also displays 8.0.0 , as expected, but why only with sudo ?

  • And sudo node -v ? - D-side
  • with such a command 8.0.0. And what is the reason? - yureev
  • n stable (without sudo ) work? - D-side
  • the error did not deduce - yureev
  • Affected the output of node -v ? - D-side

3 answers 3

What is the system? In Ubuntu, for example, there are different branches, 6. *, 7. *, 8. *, etc. There is also a tool to manage this. The version node (for example) 6.3.1 can be upgraded to 6.3.2, despite the fact that there are already 7. *, 8. *, etc.

  • n is this tool. - D-side

Try to demolish the old version and add manually the repositories for the new branch (at the time of installation, you can disable all others, then enable):

 curl -sL https://deb.nodesource.com/setup_8.x | -E bash – 

I suppose the point is that in your list of repositories there are only old lists of the node (this is often found if you do not manually register the node repository).

     sudo n stable 

    Oh, you have n . The version manager, executed by the technology, “put the necessary version in the home folder and change the environment variables so that this version is used by default”, which is convenient for development. From the same series RVM, rbenv, GVM.

    The fact is that sudo starts a new shell session on behalf of another user. In this case, root . And configuration changes (new installed versions, default version) are saved in its folders and are relevant only for shell sessions on its behalf (or with its configuration; I have never seen it done so, but I don’t see what is stopping it) .

    Using n with sudo , you change the environment for root , not for yourself.