nodejs vs node on ubuntu 12.04

2018-12-31 14:30发布

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 such file or directory

I can see node in the /usr/sbin/ directory, though.

Writing npm --version shows 1.3.5
Writing nodejs --version shows v0.10.15

Also, I can see node in the /usr/bin/ directory.

So, how do I get node working?

Also, If I use zsh instead of bash, then node command works.

20条回答
弹指情弦暗扣
2楼-- · 2018-12-31 15:29

I had created a symlink, but it still wasn't working.

I forgot to restart my terminal (my putty connection). After I had it worked without the symlink :)

查看更多
琉璃瓶的回忆
3楼-- · 2018-12-31 15:30

If you are on an AWS EC2 instance running an Ubuntu instance (tested on Ubuntu 16.x), then these steps might work for you:

    sudo apt-get update
    sudo apt-get --purge remove node -y
    sudo apt-get --purge remove nodejs -y
    sudo apt-get --purge remove legacy-node -y
    sudo rm  /usr/bin/node
    curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
    sudo apt-get install nodejs -y
    node -v

If all is correct the last command shall have an output like : v6.x.x

If not then run the following:

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

Hopefully this will help. It helped me magically (hehe).

查看更多
登录 后发表回答