mac 安装nodejs环境

官网下载可执行文件压缩包

wget https://nodejs.org/dist/v14.16.1/node-v14.16.1-darwin-x64.tar.gz
node-v14.16.1-darwin-x64.tar.gz

解压

tar zxf node-v14.16.1-darwin-x64.tar.gz

创建可执行文件软链接

ln -s ~/Downloads/node-v14.16.1-darwin-x64/bin/node /usr/local/bin
ln -s ~/Downloads/node-v14.16.1-darwin-x64/bin/npm /usr/local/bin
ln -s ~/Downloads/node-v14.16.1-darwin-x64/bin/npx /usr/local/bin

编辑环境变量

vi ~/.bash_profile
export PATH=$PATH:~/Downloads/node-v14.16.1-darwin-x64
source ~/.bash_profile

测试

npm --version
node --version
npx --version

更换为淘宝镜像

# https://registry.npmjs.org/
# 默认官方源国内下载较慢
npm config set registry https://registry.npm.taobao.org
npm config get registry

安装asar

npm install -g asar
ln -s /Users/fangqi/Downloads/node-v14.16.1-darwin-x64/bin/asar /usr/local/bin
asar --version

你可能感兴趣的:(mac 安装nodejs环境)