The Problem of ubuntu Downloading nodejs

  node.js, question

Usesudo add-apt-repository ppa:chris-lea/node.jsA new one has been installed.nodejs, you can enternodejsEnvironment, inputconsole.logCan also be printed out, but inputnode -vBut there was no response
So I downloaded itnodeTo compile the source code of,pythonYes2.7.6; Still, the installation was unsuccessful. What do you need to pay attention to?

图片描述

According to your screenshot, when installing node, the installation location is /usr/local/bin/node, but this location requires root permission, and the error indicated in the screenshot is that you do not have sufficient permission and node has not been installed successfully. If you compile and install with source code, remember to add sudo to the final installation. And when you are executing nodejs, the screenshot also indicates that your nodejs are not installed, but you can use themsudo apt-get install nodejsThis command to install, this is because you added ppa before can be installed in this way.

In addition, I would like to add that the ppa method you are using is very old, even if the installation is successful, it is also a very old version. This ppa has not been updated for a long time. Now the ubuntu software warehouse already has node, so you can use it first.sudo apt-add-repository -r ppa:chris-lea/node.js-develDelete this ppa and install node in warehouse inside:

sudo apt-get install nodejs

If you find that the nodejs version of warehouse inside is not high enough, you can update the warehouse and software version:

sudo apt-get update
 sudo apt-get upgrade

You can also use the source code to compile and install node, which is also very simple. Download the source code package of node, decompress, and enter the directory for execution:

./configure && make && sudo make install

Add:
Whynode -vNo output?

Ubuntu’s warehouse already has a software package called node, which can be executed.aptitude search node`Look, this is a software name that existed before nodejs and has already been used, so ubuntu can only change the node used for js development to nodejs. If the system has already installed this software, execute itnode -vNot nodejs node, it has nothing to do with nodejs, its-vParameters do not show anything.

Node or nodejs?

Useapt-get install nodejsMethod installation, or ppa method installation, the command should be called nodejs, should be usednodejs -vTo test. However, if it is compiled and installed using source code (default installed to /usr/local/bin, unless prefix parameter is specified), it is also called node. this node is a real nodejs node, so in order to avoid confusion with node in ubuntu warehouse, it is suggested to rename node nodejs after installation.