linux(ubuntu21.10):安装node v16.13.1
一,下载node
1,官网:
https://nodejs.org/en/
如图:
2,复制下载链接后,从命令行下载:
liuhongdi@lhdpc:/usr/local/source$ wget https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/29/linux-ubuntu21-10-an-zhuang-node-v16-13-1/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,解压node安装包
liuhongdi@lhdpc:/usr/local/source$ xz -d node-v16.13.1-linux-x64.tar.xz liuhongdi@lhdpc:/usr/local/source$ tar -xvf node-v16.13.1-linux-x64.tar
三,安装node
1,移动到安装目录
liuhongdi@lhdpc:/usr/local/source$ mv node-v16.13.1-linux-x64 /usr/local/soft/
2,创建符号链接,供直接从命令行访问无需输入路径
liuhongdi@lhdpc:/usr/local/source$ sudo ln -s /usr/local/soft/node-v16.13.1-linux-x64/bin/node /usr/local/bin/node [sudo] liuhongdi 的密码: liuhongdi@lhdpc:/usr/local/source$ sudo ln -s /usr/local/soft/node-v16.13.1-linux-x64/bin/npm /usr/local/bin/npm
3,查看效果:
liuhongdi@lhdpc:/usr/local/source$ node -v v16.13.1 liuhongdi@lhdpc:/usr/local/source$ npm -v 8.1.2
四,配置npm使用国内源
1,查看npm的当前配置
liuhongdi@lhdpc:/usr/local/source$ npm config list ; node bin location = /usr/local/soft/node-v16.13.1-linux-x64/bin/node ; cwd = /usr/local/source ; HOME = /home/liuhongdi ; Run `npm config ls -l` to show all defaults.
2,设置npm使用淘宝的源
liuhongdi@lhdpc:/usr/local/source$ npm config set registry https://registry.npm.taobao.org
3,查看是否生效
liuhongdi@lhdpc:/usr/local/source$ npm config list ; "user" config from /home/liuhongdi/.npmrc registry = "https://registry.npm.taobao.org/" ; node bin location = /usr/local/soft/node-v16.13.1-linux-x64/bin/node ; cwd = /usr/local/source ; HOME = /home/liuhongdi ; Run `npm config ls -l` to show all defaults.
五,npm升级npm自身
1,查看当前版本
liuhongdi@lhdpc:/usr/local/source$ npm -v 8.1.2
2,升级npm
liuhongdi@lhdpc:/usr/local/source$ npm install -g npm removed 8 packages, and changed 24 packages in 7s 10 packages are looking for funding run `npm fund` for details npm notice npm notice New minor version of npm available! 8.1.2 -> 8.3.0 npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.3.0 npm notice Run npm install -g npm@8.3.0 to update! npm notice
3,查看升级后的效果
liuhongdi@lhdpc:/usr/local/source$ npm -v 8.3.0
六,查看linux的版本
liuhongdi@lhdpc:/usr/local/source$ cat /etc/os-release PRETTY_NAME="Ubuntu 21.10" NAME="Ubuntu" VERSION_ID="21.10" VERSION="21.10 (Impish Indri)" VERSION_CODENAME=impish ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=impish