Henry
发布于 2024-10-14 / 25 阅读
0
0

Node.js - 安装

简介

由于开发需要安装 Node.js,因此做个记录。

安装步骤

官方参考文档

使用 nvm 安装 Node.js v20.18.0 (LTS) 版本

安装 nvm

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

安装结果

(base) myserver@myserver:~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16555  100 16555    0     0  28287      0 --:--:-- --:--:-- --:--:-- 28347
=> Downloading nvm as script to '/home/myserver/.nvm'

=> Appending nvm source string to /home/myserver/.bashrc
=> Appending bash_completion source string to /home/myserver/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

重启 terminal 后开始安装 node js

# download and install Node.js (you may need to restart the terminal)
nvm install 20

安装结果

(base) myserver@myserver:~$ nvm install 20
Downloading and installing node v20.18.0...
Downloading https://nodejs.org/dist/v20.18.0/node-v20.18.0-linux-x64.tar.xz...
####################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v20.18.0 (npm v10.8.2)
Creating default alias: default -> 20 (-> v20.18.0)

查看安装信息

(base) myserver@myserver:~$ node -v
v20.18.0
(base) myserver@myserver:~$ npm -v
10.8.2

至此, Node.js 的安装已完成。


评论