进入nodejs官网,选择mac,选择安装方式,选择版本即可获得安装命令 直接执行即可
具体脚本
# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash# in lieu of restarting the shell
\. "$HOME/.nvm/nvm.sh"# Download and install Node.js:
nvm install 14# Verify the Node.js version:
node -v # Should print "v14.21.3".
nvm current # Should print "v14.21.3".# Verify npm version:
npm -v # Should print "6.14.18".
执行后查看node版本