Home > Web Front-end > JS Tutorial > Why doesn\'t the \'node\' command work after installing Node.js on Ubuntu 12.04?

Why doesn\'t the \'node\' command work after installing Node.js on Ubuntu 12.04?

Mary-Kate Olsen
Release: 2024-11-03 05:00:31
Original
870 people have browsed it

Why doesn't the 'node' command work after installing Node.js on Ubuntu 12.04?

Nodejs vs Node on Ubuntu 12.04

When installing Node.js on Ubuntu 12.04, you may encounter the issue where the node command doesn't exist in the terminal. This is due to a naming conflict with the Amateur Packet Radio Node Program, which has resulted in the Node.js binary being renamed to nodejs.

To resolve this issue, you need to create a symbolic link from /usr/bin/node to /usr/bin/nodejs. This can be done using the following command:

sudo ln -s `which nodejs` /usr/bin/node
Copy after login

Alternatively, if you use a non-standard shell, you can hardcode the path found with which nodejs:

sudo ln -s /usr/bin/nodejs /usr/bin/node
Copy after login

This will create the missing node symlink and allow you to use the Node.js commands with the node alias.

Additionally, if you use the zsh shell instead of bash, the node command should work without modification. However, if the issue persists, you can try the following additional solutions:

  • Install Node.js using alternatives:

    sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
    Copy after login
  • Purge and reinstall Node.js:

    sudo apt-get --purge remove node
    sudo apt-get --purge remove nodejs
    sudo apt-get install nodejs
    Copy after login

The above is the detailed content of Why doesn\'t the \'node\' command work after installing Node.js on Ubuntu 12.04?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template