nodejs vs node on ubuntu 12.04

前端 未结 20 1952
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:11

    I had the same issue symbolic link helped me out: sudo ln -s /usr/bin/nodejs /usr/bin/node after that sudo npm install -g phantomjs-prebuilt

    went smoothly

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

    I think this is it:

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

    Using Debian alternatives.

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

    Late answer, but for up-to-date info...

    If you install node.js using the recommend method from the node github installation readme, it suggests following the instructions on the nodesource blog article, rather than installing from the out of date apt-get repo, node.js should run using the node command, as well as the nodejs command, without having to make a new symlink.

    This method from article is:

    # Note the new setup script name for Node.js v0.12
    curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
    
    # Then install with:
    sudo apt-get install -y nodejs
    

    Note that this is for v0.12, which will get likely become outdated in the not to distant future.

    Also, if you're behind a corporate proxy (like me) you'll want to add the -E option to the sudo command, to preserve the env vars required for the proxy:

    curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -

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

    Apparently the solution differs between Ubuntu versions. Following worked for me on Ubuntu 13.10:

    sudo apt-get install nodejs-legacy
    

    HTH

    Edit: Rule of thumb:

    If you have installed nodejs but are missing the /usr/bin/node binary, then also install nodejs-legacy. This just creates the missing softlink.

    According to my tests, Ubuntu 17.10 and above already have the compatibility-softlink /usr/bin/node in place after nodejs is installed, so nodejs-legacy is missing from these releases as it is no more needed.

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

    Best way to install nodejs is through NVM (Node Version Manager)

    Delete previous versions :

    $ sudo apt-get purge node
    $ sudo apt autoremove

    Also delete all node_modules by $ sudo rm -rf node_modules in the directory containing this folder.

    Node & Nodejs are technically the same thing. Just the naming changed.

    First Install or update nvm

    to run as root

    $ sudo su 

    Then

    $ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash

    OR

    $ wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.7/install.sh | bash

    Check nvm to path

    $ source ~/.profile
    $ nvm ls-remote

    if you get error regarding the listing then install git.

    $ sudo apt-get install git

    Re-run :

    $ nvm ls-remote
    OR
    $ sudo nvm ls-remote

    $ nvm install version-you-require 

    Checking Version

    # node --version
    nvm use version-you-require

    INFORMATION COURTESY :

    https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps

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

    Adding to @randunel's correct answer (can't yet comment on SO):

    I also had to symlink /usr/local/bin/node to /usr/bin/nodejs as well.

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

    Apparently, this was overriding the /usr/bin/ node command.

    No idea how that got set, but hope it helps someone else as it was a pain to figure out why the above wasn't working for me.

    0 讨论(0)
提交回复
热议问题