Install Node.js on Ubuntu

2019-01-12 13:35发布

I'm trying install Node.js on Ubuntu 12.10, but the terminal shows me an error about lost packages. I tried with this:

sudo apt-get install python-software-properties 
sudo add-apt-repository ppa:chris-lea/node.js 
sudo apt-get update 
sudo apt-get install nodejs npm

But when I came to the last line sudo apt-get install nodejs npm shows this error:

Failed to install some packages. This may mean that
you requested an impossible situation or if you are using the distribution
distribution that some required packages have not yet been created or been
been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nodejs: Conflicts: npm
E: Failed to correct problems, you have held broken packages.

Then I uninstalled the ppa:chris-lea/node.js and I was trying a second option:

sudo apt-get install node.js
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

The same error, the terminal says npm is the latest version but also shows me the text I shown in the top. I think the problem is ppa:chris-lea/node.js but I don't know how solve it.

15条回答
相关推荐>>
2楼-- · 2019-01-12 13:37

My apt-get was old and busted, so I had to install from source. Here is what worked for me:

# get the latest version from nodejs.org. At the time of this writing, it was 0.10.24
curl -o ~/node.tar.gz http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
cd
tar -zxvf node.tar.gz
cd node-v0.6.18
./configure && make && sudo make install

These steps were mostly taken from joyent's installation wiki

查看更多
闹够了就滚
3楼-- · 2019-01-12 13:39

I personally do it this way:

sudo apt-get install python g++ make
wget http://nodejs.org/dist/node-latest.tar.gz
tar xvfvz node-latest.tar.gz
cd node-v0.12.0
./configure
make
sudo make install

If you want to install particular version than download the version you want from nodejs site and execute the last tree steps.
I would strongly suggest not using the default nodejs package from the distro market because it would be probably outdated. (i.e. the current for the time of writing this in the ubuntu market is v0.10.25 which is too outdated compared to the latest (v0.12.0)).

查看更多
霸刀☆藐视天下
4楼-- · 2019-01-12 13:40

You can use nvm to install nodejs. It allows you work with different versions without conflicts.

查看更多
Explosion°爆炸
5楼-- · 2019-01-12 13:45
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.19.0/install.sh | bash    

nvm install v0.10.33

just use nvm for node version control nvm

查看更多
Animai°情兽
6楼-- · 2019-01-12 13:47

Simply follow the instructions given here:

Example install:

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

It installs current stable Node on the current stable Ubuntu. Quantal (12.10) users may need to install the software-properties-common package for the add-apt-repository command to work: sudo apt-get install software-properties-common

As of Node.js v0.10.0, the nodejs package from Chris Lea's repo includes both npm and nodejs-dev.

Don't give sudo apt-get install nodejs npm just sudo apt-get install nodejs

查看更多
在下西门庆
7楼-- · 2019-01-12 13:47
sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
git clone git://github.com/ry/node.git
cd node
./configure
make
sudo make install

http://jstricks.com/install-node-js/

查看更多
登录 后发表回答