美文网首页
如何在Linux上通过二进制存档安装Node.js?

如何在Linux上通过二进制存档安装Node.js?

作者: 方圆百里找对手 | 来源:发表于2018-12-28 09:35 被阅读0次

How to install Node.js via binary archive on Linux?

  1. Unzip the binary archive to any directory you wanna install Node, I use /usr/local/lib/nodejs
VERSION=v8.11.4
DISTRO=linux-x64
curl -fSL https://nodejs.org/dist/$VERSION/node-$VERSION-$DISTRO.tar.xz -o node-$VERSION-$DISTRO.tar.xz
sudo mkdir /usr/local/lib/nodejs
sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs 
  1. create a sudo link
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/node /usr/bin/node
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npm /usr/bin/npm
sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npx /usr/bin/npx
  1. Test installation using

$ node -v

$ npm version

$ npx -v

the normal output is:

➜  node -v
v8.11.4
➜  npm version
{ npm: '5.6.0',
 ares: '1.10.1-DEV',
 cldr: '31.0.1',
 http_parser: '2.7.0',
 icu: '59.1',
 modules: '57',
 nghttp2: '1.25.0',
 node: '8.11.4',
 openssl: '1.0.2n',
 tz: '2017b',
 unicode: '9.0',
 uv: '1.15.0',
 v8: '6.1.534.50',
 zlib: '1.2.11' }

相关文章

网友评论

      本文标题:如何在Linux上通过二进制存档安装Node.js?

      本文链接:https://www.haomeiwen.com/subject/lvzjlqtx.html