惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - 君临天下之徐少

nvm安装 Homebrew 安装 Less的优点 什么是nrm js 处理大数相减 React函数式组件值之useRef()和useImperativeHandle() 谷歌刷题插件安装 SSL certificate problem: unable to get local issuer certificate 错误解决 常用命令 解决Mac安装Homebrew失败 Canvas学习:globalCompositeOperation详解 React.CreateContext html让容器居中,css让容器水平垂直居中的7种方式 js下载文件防止白屏 GitHub上README.md编写教程(基本语法) 微信字体大小调整导致的H5页面错乱问题处理 G6-Editor 编辑器入门使用教程 git reset 加不加 --hard的区别 taro, h5拨打电话和发送短信
Mac安装Nvm Node开发环境
君临天下之徐少 · 2022-10-27 · via 博客园 - 君临天下之徐少

1.什么是nvm?

nvm 是 Mac 下的 node 管理工具,可以在同一台电脑上安装多个Node.js版本灵活切换。

2.安装前的准备

a. 卸载已安装到全局的 node/npm
  如果之前是在官网下载的 node 安装包,运行后会自动安装在全局目录,其中 node 命令在 /usr/local/bin/node,npm 命令在全局 node_modules 目录中,具体路径为 /usr/local/lib/node_modules/npm

b. 安装 nvm 之前最好先删除下已安装的 node 和全局 node 模块

npm ls -g --depth=0 # 查看已经安装在全局的模块,以便删除这些全局模块后再按照不同的 node 版本重新进行全局安装
sudo rm -rf /usr/local/lib/node_modules # 删除全局 node_modules 目录
sudo rm /usr/local/bin/node # 删除 node
cd  /usr/local/bin && ls -l | grep "../lib/node_modules/" | awk '{print $9}'| xargs rm # 删除全局 node 模块注册的软链

3.安装nvm

去官网查看最新版本安装命令: https://github.com/nvm-sh/nvm/blob/master/README.md

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

或者

wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

若安装报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决办法:
通过IPAddress.com首页,输入raw.githubusercontent.com查询到真实IP地址:199.232.68.133
Mac OS 系统:打开终端(Terminal)
默认位置在 启动台–>其他–>终端在终端输入以下命令:sudo vi /etc/hosts

i 修改,在尾部追加内容:199.232.68.133 raw.githubusercontent.com

然后:wq保存即可

4. 或者通过brew安装

brew install nvm
编辑配置文件,vim ~/.bash_profile,文件中写入如下内容
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
输入source ~/.bash_profile 保存。

5. 安装node指定版本

nvm ls-remote // 查看所有的node可用版本
nvm list // 查看已安装node版本
nvm install 版本号 // 下载指定node版本,如nvm install v11.14.0
nvm use 版本号 // 使用指定版本
nvm alias default // 设置默认版本,每次启动终端都使用该版本

6. 通过 n 来管理 node 版本

可以安装 n 来管理和变更 node 版本。

安装 n
变更 node 版本