本文介绍了如何在Linux上安装节点二进制分发文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我的生产服务器(Centos 5.9)无法编译nodejs,可能是因为它的gcc仅为4.1.2(建议使用4.2或更高版本),所以我尝试安装二进制文件.

My production server (Centos 5.9) won't compile nodejs, possibly because it's gcc is only 4.1.2 (4.2 or above is recommended) so I've trying to install the binaries.

$ wget http://nodejs.org/dist/v0.10.22/node-v0.10.22-linux-x86.tar.gz
$ tar -zxvf node-v0.10.22-linux-x86.tar.gz
$ cd node-v0.10.22-linux-x86
$ sudo cp bin/* /usr/local/bin
$ sudo cp -R lib/* /usr/local/lib
$ sudo cp -R share/* /usr/local/share

现在要进行测试:

$ node -v  # => v0.10.22
$ man node # looks fine
$ npm -v   # UH OH, PROBLEM - Cannot find module 'npmlog'

现在(记住我是node的一个完整的初学者),我进行了一些搜索,发现有一个名为NODE_PATH的环境变量,所以我尝试了:

Now (keeping in mind I'm a complete beginner at node) I did some searching and found there's an environment variable called NODE_PATH, so I tried:

$ export NODE_PATH=/usr/local/lib/node_modules
$ npm -v   # SAME PROBLEM - Cannot find module 'npmlog'

因此,我然后找出了npmlog的住处并尝试相应地修改NODE_PATH:

So then I found out where npmlog lives and tried modifying NODE_PATH accordingly:

$ find /usr/local/lib -name npmlog # => /usr/local/lib/node_modules/npm/node_modules/npmlog
$ export NODE_PATH=/usr/local/lib/node_modules/npm/node_modules
$ npm -v   # DIFFERENT PROBLEM - Can't find '../lib/npm.js'

在这个阶段,经过更多无助的谷歌搜索后,我认为自己已不知所措,并决定寻求帮助.谁能告诉我我在做什么错?

At this stage, after more unhelpful googling, I decided I was in over my depth and decided to ask for help. Can anyone tell me what I'm doing wrong?

推荐答案

进行干净的NPM重新安装要快得多,这将删除断开的"链接:

It is much faster to do clean NPM reinstall which will remove "broken" links:

wget https://npmjs.org/install.sh

chmod +x install.sh
sudo ./install.sh

然后它将要求您删除旧的NPM链接

Then it will ask you to remove old NPM link

这篇关于如何在Linux上安装节点二进制分发文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 12:07