Ubuntu安装NodeJs

之前使用apt命令安装node,但是安装之后每次执行都要sudo,比较麻烦。通过一下脚本可以将node安装到个人home下,以后执行就不用sudo了。

1
2
3
4
5
6
7
8
9
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=$HOME/local
make install
curl -L https://www.npmjs.com/install.sh | sh