详解如何在linuxmint上用源码包安装nodejs
第一步:安装依赖包
因为Linuxmint 和 Ubuntu 同属 Debian系的Linux,而且Linuxmint是建立在Ubuntu的基础上的,所以Ubuntu下的命令和包,Linuxmint同样适用。
1. 安装python 2.6版或者更高(linuxmint默认都已安装,可以在terminal中使用 pyhton -v 命令查看python版本)。
2. 安装其他依赖包: (具体需要什么依赖可以去git上去找,https://github.com/lookphp/node)
Prerequisites:
gccandg++4.8 or newer, orclangandclang++3.4 or newer- Python 2.6 or 2.7
- GNU Make 3.81 or newer
- libexecinfo (FreeBSD and OpenBSD only)
sudo apt-get install g++ clang curl libssl-dev apache2-utils
3. 安装git工具:
sudo apt-get install git-core
第二步:获取源码(我是去官网下载的源码,如下)
去github上克隆:
git clone git://github.com/joyent/node.git
等待下载完成,大小为20+m。
wget http://nodejs.org/dist/v0.6.14/node-<版本号>.tar.gz
第三步:指定编译版本,重要!
git版:
1.先进入存放下载源码的文件夹:
cd node
2. 指定迁出版本:
git checkout v0.4.10
这里非常重要,因为目前最新的node版本为0.5.5-pre,但是很多常用的包仅支持到0.4.10(比如express),所以如果使用最新版node的话,会导致npm无法下载相应的包。
3. 指定路径,编译执行:
mkdir ~/local
./configure –prefix=$HOME/local/node
make
make install
echo ‘export PATH=$HOME/local/node/bin:$PATH’>>~/.profile
echo ‘export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules’>>~/.profile
source ~/.profile
tar zxvf node-<版本号>.tar.gz
cd node-<版本号>
./configure --prefix=$HOME/local/node
make //make的时间根据电脑的配置和安装需要,时间不同,执行完make,之后需要的就是等待~等待~,千万别再乱动其他了
sudo make install
echo ‘export PATH=$HOME/local/node/bin:$PATH’>>~/.profile
echo ‘export NODE_PATH=$HOME/local/node:$HOME/local/node/lib/node_modules’>>~/.profile
source ~/.profile
第四步:设置环境变量
如果想重启后还能继续直接使用node命令,那么需要设置环境变量:
使用命令
sudo gedit /etc/profile
打开配置文件,在文件最后中添加如下两行:
export PATH=”$HOME/local/node/bin:$PATH”
export NODE_PATH=”$HOME/local/node:$HOME/local/node/lib/node_modules”
保存后重启系统使设置生效。
第五步:安装npm
安装完成后,验证是否安装成功,输入
node –v
curl http://npmjs.org/install.sh | sh
npm –v
根据需要,安装相应的包,例如express: (这里不建议进行安装express,如要安装可看另一个教程 http://www.cnblogs.com/lookphp/p/5133766.html)
如果输入该命令后长时间没有反应,可以通过添加 -verbose参数查看执行的详细信息,即:
npm install express -verbose
一般情况下无法下载有两个原因:
1. 网速太慢,超时退出。
2. node的版本太新,当前下载的包不支持。(解决方法在第三步已说明。)
第六步:测试HelloWorld程序
将以下代码保存为一个hello.js的文件
var http = require('http');
var server = http.createServer();
// 为request事件绑定处理函数
// 也可以使用server.addListener
server.on('request', function(req, res){
res.writeHead(,{'Content-Type':'text/plain'});
res.write('hello world');
console.log('hello world');
res.end();
});
server.listen(,'127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
详解如何在linuxmint上用源码包安装nodejs的更多相关文章
- 详解如何在CentOS7中使用Nginx和PHP7-FPM安装Nextcloud
转载地址:https://www.jb51.net/article/109382.htm 这篇文章主要介绍了详解如何在CentOS7中使用Nginx和PHP7-FPM安装Nextcloud,会通过 N ...
- zookeeper使用详解(命令、客户端、源码)
1. zookeeper使用详解(命令.客户端.源码) 1.1. 前言 zookeeper我们常用来做分布式协调中间件,很多时候我们都接触不到它的原理和用法,我对他的了解也仅限于知道它可以做分布式 ...
- Linux学习(二十)软件安装与卸载(三)源码包安装
一.概述 源码包安装的优点在于它自由程度比较高,可以指定目录与组件.再有,你要是能改源码也可以. 二.安装方法 步骤 1.从官网或者信任站点下载源码包 [root@localhost ~]# wget ...
- RedHat系列软件管理(第二版) --源码包安装
RedHat系列软件管理 --源码包安装 源码包特点: 拥有广泛的平台支持性,可以装在所有的类UNIX操作系统上,不用考虑CPU架构. 灵活性,可以在安装过程中指定特有的选项. 定制度非常高,可以自己 ...
- Linux源码包安装程序
★安装OS时,建议提前安装开发组件 CentOS 6:Development Tools.Server Platform DevelopmentCentOS 7:Development Tools.D ...
- Linux yum源码包安装和卸载
Linux 下的绝大多数源码包都是用 C 语言编写的,还有少部分是用 C++ 等其他程序语言编写的.所以,要想安装源码包,必须安装 C 语言编译器 gcc(如果是用 C++ 编写的程序,则还需要安装 ...
- yum更换国内源、yum下载rpm包、源码包安装 使用介绍
第5周第4次课(4月19日) 课程内容: 7.6 yum更换国内源7.7 yum下载rpm包7.8/7.9 源码包安装 7.6 yum更换国内源 当yum仓库的软件不好用时,例如很多yum源都是国外的 ...
- yum换源,rpm包下载,源码包安装
一.yum更换源 yum自带源地址一般斗是国外的,可能下载速度略慢,我们可以自己换成国内的源,比如163等.比如配置163的yum源:1.先删除默认源文件dvd.repo # rm -f /etc/y ...
- yum 仓库搭建与源码包安装实战
目录 一.yum 仓库自建示例: 二.源码包安装实践 基础环境 服务端配置 下载及安装fpm软件 客户端: 一.yum 仓库自建示例: 1.安装ftp服务 yum -y install vsftpd ...
随机推荐
- PK投票效果
/** *createTime:2015-07-21 *updateTime:2015-06-22 *author:刘俊 *Description:PK投票 *phone:13469119119 ** ...
- Ubuntu Codeblocks Installation
Download and Installation sudo add-apt-repository ppa:damien-moore/codeblocks sudo apt update sudo a ...
- HttpWebRequest.Method 属性
public static void GetHead(string url) { var http = (HttpWebRequest)WebRequest.Create(url); http.Met ...
- 给ie浏览器添加推荐浏览器提示
<script type="text/javascript"> var isIE = !!window.ActiveXObject; var isIE6 = isIE ...
- Java Keyword -- super
Reference: super When we override superclass's methods, but still want to invoke them, we can use ke ...
- 2.x ESL第二章习题 2.8
题目 代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 3 ...
- tomcat7 https 成功测试
1,生成证书
- RIAidea – Focus on Flash/Flex/AIR » About Me
RIAidea – Focus on Flash/Flex/AIR » About Me Browse > Home > About Me Tuesday, May 20, 2014 | ...
- Vanya and Scales(思维)
Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Dice Notation(模拟)
Dice Notation Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Submit ...