Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs 源码/二进制文件安装 #29

Open
weekeight opened this issue Sep 8, 2015 · 0 comments
Open

nodejs 源码/二进制文件安装 #29

weekeight opened this issue Sep 8, 2015 · 0 comments
Labels

Comments

@weekeight
Copy link
Owner

源码安装

编译时间有点长,不喜则直接用别人编好的二进制文件

# 下载解压
wget https://nodejs.org/dist/v0.10.5/node-v0.12.7.tar.gz
tar -zvxf node-v0.12.7.tar.gz

# 配置编译环境,安装到 /opt/node/v0.12.7
./configure --prefix=/opt/node/v0.12.7

# 编译及安装
make && make install

# 配置环境变量
# 在/etc/profile.d目录下建立node.sh脚本文件并输入如下
#set for nodejs  
export NODE_HOME=/opt/node/v0.12.7  
export PATH=$NODE_HOME/bin:$PATH  
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH

# 测试验证
node -v

二进制文件安装

# 下载解压二进制文件
wget https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
tar -zvxf node-v0.12.7-linux-x64.tar.gz

# 测试验证二进制文件
./node-v0.12.7-linux-x64/bin/node -v

# 让 nodejs 能在命令行全局执行(有两种方式)

1. 配置环境变量
pwd  # 获取到当前目录的绝对路径,例如是 /Users/weekeight/node-v0.12.7-linux-x64/bin
vim /etc/profile
修改 PATH ,将上面的路径添加到末尾,冒号隔开
source /etc/profile

2. 创建软连接
ln -s  /Users/weekeight/node-v0.12.7-linux-x64/bin/node /usr/local/bin/node
ln -s  /Users/weekeight/node-v0.12.7-linux-x64/bin/npm /usr/local/bin/npm

# 完成测试验证
node -v
@weekeight weekeight changed the title nodejs 源码安装 nodejs 源码/二进制文件安装 Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant