search

Home  >  Q&A  >  body text

node.js - ubuntu 16.04 使用nvm安装nodejs后,切换用户就不见了

ubuntu 16.04 使用root权限,nvm安装nodejs后,输入node -v 是有版本号的,npm -v也是有的,然后切换到另一个用户,发现node -v 提示没有安装nodejs,然后再切换到root,发现之前安装的nodejs也没了!这是什么情况?

ringa_leeringa_lee2922 days ago770

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 15:03:29

    nvm will only be available to your user account (the one used to
    install nvm)

    Available to all users if needed. A soft link is required.
    In addition, it is recommended to use NodeSource’s binary installation script under Ubuntu https://github.com/nodesource...

    # Using Ubuntu
    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
    sudo apt-get install -y nodejs

    reply
    0
  • 阿神

    阿神2017-04-17 15:03:29

    This should be the reason for the environment variable path. Check whether another user's path contains the nodejs execution directory.
    In addition, su - username, is different from su root. I wonder if you switch back to root and use su root.
    If su root, then the current environment variable path is still that of the previous user.

    reply
    0
  • Cancelreply