brew安装nvm、node及配置

简介: brew安装nvm、node及配置

邪恶进攻正直的心灵,从不来不是那么大张旗鼓的,它总是想法子来偷袭,总戴着某种诡辩的面具,还时常披着道德的外衣。——卢俊

brew安装nvm

rew install nvm

安装很慢,配置下镜像?.bash_profile

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/bottles"

安装完毕后执行brew info nvm

achaodeMacBook-Pro:~ achao$ brew info nvm
==> nvm: stable 0.39.3 (bottled), HEAD
Manage multiple Node.js versions
https://github.com/nvm-sh/nvm
/opt/homebrew/Cellar/nvm/0.39.3 (9 files, 190.6KB) *
  Poured from bottle using the formulae.brew.sh API on 2023-06-26 at 13:22:48
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nvm.rb
License: MIT
==> Options
--HEAD
  Install HEAD version
==> Caveats
Please note that upstream has asked us to make explicit managing
nvm via Homebrew is unsupported by them and you should check any
problems against the standard nvm install method prior to reporting.
You should create NVM's working directory if it doesn't exist:
  mkdir ~/.nvm
Add the following to your shell profile e.g. ~/.profile or ~/.zshrc:
  export NVM_DIR="$HOME/.nvm"
  [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"  # This loads nvm
  [ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion
You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/Cellar/nvm/0.39.3 will destroy any nvm-installed Node installations
upon upgrade/reinstall.
Type `nvm help` for further information.
Bash completion has been installed to:
  /opt/homebrew/etc/bash_completion.d
==> Analytics
install: 18,642 (30 days), 202,744 (90 days), 212,500 (365 days)
install-on-request: 18,642 (30 days), 202,744 (90 days), 212,500 (365 days)
build-error: 0 (30 days)

然后叫我们先创建nvm的工作目录

mkdir ~/.nvm

然后添加这一段到 ~/.bash_profile 或者 ~/.zshrc(没有就创建):

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

然后我们保存退出,执行source .bash_profile

achaodeMacBook-Pro:~ achao$ nvm -v
0.39.3

说明配置ok,环境变量生效

接下来配置nvm镜像,在.bash_profile,添加

export NVM_NODEJS_ORG_MIRROR=http://mirrors.cloud.tencent.com/nodejs-release/

下载最后一个LTS版本

achaodeMacBook-Pro:~ achao$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v18.16.1...
Downloading http://mirrors.cloud.tencent.com/nodejs-release//v18.16.1/node-v18.16.1-darwin-arm64.tar.xz...
######################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v18.16.1 (npm v9.5.1)
achaodeMacBook-Pro:~ achao$ node -v
v18.16.1

配置npm镜像

achaodeMacBook-Pro:~ achao$ npm config set registry http://mirrors.cloud.tencent.com/npm/
achaodeMacBook-Pro:~ achao$ npm config get registry
http://mirrors.cloud.tencent.com/npm/


相关文章
|
25天前
|
消息中间件 Web App开发 JavaScript
Node.js【简介、安装、运行 Node.js 脚本、事件循环、ES6 作业队列、Buffer(缓冲区)、Stream(流)】(一)-全面详解(学习总结---从入门到深化)
Node.js【简介、安装、运行 Node.js 脚本、事件循环、ES6 作业队列、Buffer(缓冲区)、Stream(流)】(一)-全面详解(学习总结---从入门到深化)
47 0
|
2天前
|
JavaScript Windows 内存技术
通过Nvm安装和管理NodeJS
通过Nvm安装和管理NodeJS
38 0
通过Nvm安装和管理NodeJS
|
3天前
|
JavaScript Ubuntu 前端开发
百度搜索:蓝易云【Linux下Nodejs安装三种方式及开发环境】
请注意,为了保持开发环境的稳定和可靠,建议使用LTS(长期支持)版本的Node.js,并避免使用过旧或过新的非稳定版本。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
13 1
|
22天前
|
JavaScript iOS开发 MacOS
掌握NVM、NRM和NPM:Node.js开发的利器
掌握NVM、NRM和NPM:Node.js开发的利器
30 0
|
22天前
|
JavaScript Shell 开发者
释放Node.js的潜力:NVM指南,让版本管理变得轻松
释放Node.js的潜力:NVM指南,让版本管理变得轻松
72 1
|
23天前
|
JavaScript 内存技术
nvm安装和切换node使用版本
nvm安装和切换node使用版本
|
8天前
|
JSON JavaScript 前端开发
JS服务端技术—Node.js知识点
JS服务端技术—Node.js知识点
39 0
|
27天前
|
JavaScript
node下的two.js调用one.js出现无法编译问题 Cannot find module ‘c:
node下的two.js调用one.js出现无法编译问题 Cannot find module ‘c:
34 0
|
1月前
|
JavaScript
Turndown 源码分析:五、节点相关`root-node.js`和`node.js`
Turndown 源码分析:五、节点相关`root-node.js`和`node.js`
18 0
|
1月前
|
JavaScript 前端开发 API
Node.js【简介、安装、运行 Node.js 脚本、事件循环、ES6 作业队列、Buffer(缓冲区)、Stream(流)】(一)-全面详解(学习总结---从入门到深化)(下)
Node.js【简介、安装、运行 Node.js 脚本、事件循环、ES6 作业队列、Buffer(缓冲区)、Stream(流)】(一)-全面详解(学习总结---从入门到深化)
26 0