nodejs vs node on ubuntu 12.04

前端 未结 20 1950
Happy的楠姐
Happy的楠姐 2020-11-22 12:29

I installed nodejs on ubuntu from instructions given here

When I write node --version in the terminal I see this :
-bash: /usr/sbin/node: No

相关标签:
20条回答
  • 2020-11-22 13:01

    Just use NVM(Node Version Manager) - https://github.com/creationix/nvm

    It has become the standard for managing Node.js.

    When you need a new version:

    nvm install NEW_VER
    nvm use XXX
    

    If something goes wrong you can always go back with

    nvm use OLD_VER
    
    0 讨论(0)
  • 2020-11-22 13:03

    I am new to all this, but for me a simple alias worked:

    alias node='env NODE_NO_READLINE=1 rlwrap nodejs'
    

    at least for running things directly in bash and executing .js files.

    0 讨论(0)
  • 2020-11-22 13:03

    Will be helpful for absolute beginners

    Although, you have got the answer, just wanted to point out that the node command (without any parameters) will start node in REPL read-eval-print-loop mode to execute raw javascript code.

    Another way to use node command is by providing it a js file as a parameter. This is how we mostly use it.

    0 讨论(0)
  • 2020-11-22 13:07

    It's optional to remove the existing node and nodejs, but have to do alternatively install the latest 7.x nodejs.

    curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    0 讨论(0)
  • 2020-11-22 13:09

    You need to manually create a symlink /usr/bin/node. Shortcut for bash compatible shells:

    sudo ln -s `which nodejs` /usr/bin/node
    

    Or if you use non-standard shells, just hardcode the path you find with which nodejs:

    sudo ln -s /usr/bin/nodejs /usr/bin/node
    

    Later edit

    I found this explanation in the link you posted

    There is a naming conflict with the node package (Amateur Packet Radio Node Program), and the nodejs binary has been renamed from node to nodejs. You'll need to symlink /usr/bin/node to /usr/bin/nodejs or you could uninstall the Amateur Packet Radio Node Program to avoid that conflict.

    Later later edit

    It's been a while since I answered this. Although the solution I posted up here worked for me several times, users have reported a few more solutions within the comments:

    From @user229115

    sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

    From AskUbuntu (user leftium)

    sudo apt-get --purge remove node
    sudo apt-get --purge remove nodejs
    sudo apt-get install nodejs
    
    0 讨论(0)
  • 2020-11-22 13:11

    I have the same issue in Ubuntu 14.04.

    I have installed "nodejs" and it's working, but only if I'm use command "nodejs". If I try to use "node" nothing happens.

    I'm fixed this problem in next way:

    1. Install nodejs-legacy

      sudo apt-get install nodejs-legacy

    After that, when I type "node" in command line I'm get an error message "/usr/sbin/node: No such file or directory"

    1. Second, what I did, it's a symbolic link on "nodejs":

      sudo ln -s /usr/bin/nodejs /usr/sbin/node
    0 讨论(0)
提交回复
热议问题