macOS Big Sur 安装 Node.js
注意
切记不要在 Node.js 官网下载安装包直接安装,否则在安装 Hexo 时会出现 EACCES
权限错误。
在Hexo 官方文档中有如下说明:
For Mac / Linux 用户
如果在尝试安装 Hexo 的过程中出现EACCES
权限错误,请遵循 由 npmjs 发布的指导 修复该问题。强烈建议 不要 使用 root、sudo 等方法覆盖权限
而在 由 npmjs 发布的指导 中有如下说明:
If you see an
EACCES
error when you try to install a package globally, you can either:
Reinstall npm with a node version manager (recommended),
or
Manually change npm’s default directory如果在尝试全局安装软件包时看到
EACCES
错误,你可以
使用 node 版本管理器重新安装npm(推荐),
或者
手动更改npm的默认目录
Reinstall npm with a node version manager 部分的说明如下:
Reinstall npm with a node version manager
This is the best way to avoid permissions issues. To reinstall npm with a node version manager, follow the steps in “Downloading and installing Node.js and npm”. You do not need to remove your current version of npm or Node.js before installing a node version manager.使用 node 版本管理器重新安装npm
这是避免权限问题的最好方法。要使用节点版本管理器重新安装npm,请按照“下载和安装Node.js和npm”中的步骤操作。在安装节点版本管理器之前,您不需要删除当前版本的npm或Node.js。
Downloading and installing Node.js and npm 部分的说明如下
We strongly recommend using a Node version manager like nvm to install Node.js and npm. We do not recommend using a Node installer, since the Node installation process installs npm in a directory with local permissions and can cause permissions errors when you run npm packages globally.
**我们强烈建议使用像nvm这样的Node版本管理器来安装Node.js和npm。**我们不建议使用Node安装程序,因为Node安装过程在具有本地权限的目录中安装npm,当您全局运行npm包时,可能会导致权限错误。
安装 Node Version Manager(nvm)
1 | curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash |
前往官网查看 Node.js 的最新版本
1 | 确认 nvm 是否安装成功 |
安装 Node.js
1 | 前往官网查看 Node.js 的最新版本 |