295 字
1 分钟
Node.js基础安装
本文将介绍安装Node.js的基本流程。
写这篇文章主要因为类似的操作过于重复,直接将其记下来,方便后续直接使用。用途和更换镜像源是一致的,只不过流程更加完整。
1. 安装
访问Node.js官网。Windows系统可直接下载.msi安装包进行安装;Linux系统可按Linux -> nvm -> npm在下拉菜单中选择,获取安装脚本。
截至目前,执行的内容应当是这样,核对没有问题可直接从官网复制并运行。(来自Node.js官网,这里默认选择v24版本)
# 下载并安装 nvm:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
# 代替重启 shell\. "$HOME/.nvm/nvm.sh"
# 下载并安装 Node.js:nvm install 24
# 验证 Node.js 版本:node -v
# 验证 npm 版本:npm -v2. 更换镜像源
更详细的内容可参见更换镜像源,这里出于简洁,默认采用https://registry.npmmirror.com。
# 1. 设置镜像源npm config set registry https://registry.npmmirror.com
# 2. 验证是否修改成功npm config get registry# 应当返回: https://registry.npmmirror.com快速使用
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash\. "$HOME/.nvm/nvm.sh"nvm install 24node -vnpm -v
npm config set registry https://registry.npmmirror.comnpm config get registry分享文章
生成精美分享图或复制链接,与更多人分享本文。
继续阅读
换条路线
从其他文章中稳定抽取
最后更新于 ,距今已过 27 天
部分内容可能已过时