debian安装nodejs

https://nodejs.org/en/download/

二进制安装

sudo wget https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
sudo tar -xvf ./node-v10.15.1-linux-x64.tar.xz

环境变量

sudo vim ~/.profile

#node
NODE_HOME=/opt/node-v11.4.0
PATH=$PATH:$NODE_HOME/bin
export PATH

查看环境变量

➜  ~ node -v && npm -v && npx -v
v10.15.1
6.4.1
6.4.1
➜  ~ whereis node
node: /opt/graalvm-ce-1.0.0-rc12/bin/node /opt/node-v10.15.1-linux-x64/bin/node
➜  ~ whereis npm
npm: /opt/graalvm-ce-1.0.0-rc12/bin/npm /opt/node-v10.15.1-linux-x64/bin/npm
➜  ~ whereis npx
npx: /opt/node-v10.15.1-linux-x64/bin/npx
➜  ~

使用淘宝源

npm set registry https://registry.npm.taobao.org \
npm set disturl https://npm.taobao.org/dist \
npm set sass_binary_site https://npm.taobao.org/mirrors/node-sass \
npm set electron_mirror https://npm.taobao.org/mirrors/electron \
npm set puppeteer_download_host https://npm.taobao.org/mirrors \
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver \
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver \
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs \
npm set selenium_cdnurl https://npm.taobao.org/mirrors/selenium \
npm set node_inspector_cdnurl https://npm.taobao.org/mirrors/node-inspector \
npm cache clean --force

检测

npm get registry

附:源码安装

下载最新版本

wget https://nodejs.org/dist/v11.4.0/node-v11.4.0.tar.gz

解压

tar -xvf node-v11.4.0.tar.gz

编译

cd node-v11.4.0
sudo ./configure --debug
sudo make -j4

安装

sudo make -j4 install 
posted @ 2018-12-13 18:05 灯塔下的守望者 阅读(...) 评论(...) 编辑 收藏