安装开发环境:
先全局安装brew:
/usr/bin/ruby -e "$(curl -fsSL raw.githubusercontent.com/Homebrew/in…)"
再安装nvm进行node版本的管理:
curl -o- raw.githubusercontent.com/nvm-sh/nvm/… | bash
修改环境变量:github.com/nvm-sh/nvm\ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "NVM_DIR/nvm.sh" ] && \. "NVM_DIR/nvm.sh"
以上Mac不会加到全局环境中,如果需要加入全局配置中需要再执行如下:
1.vim ~/.zshrc,将上面export整段内容再新增到vim里面;
2.在source ~/.zshrc刷新之前配置信息;
安装node:
nvm install 10.20.1
切换稳定版本:nvm install stable
Example:
nvm install 8.0.0 Install a specific version number
nvm use 8.0 Use the latest available 8.0.x release
nvm run 6.10.3 app.js Run app.js using node 6.10.3
nvm exec 4.8.3 node app.js Run node app.js with the PATH pointing to node 4.8.3
nvm alias default 8.1.0 Set default node version on a shell
nvm alias default node Always default to the latest available node version on a shell
当前问题:
1.无法安装维护node版本;
待验证:curl -o- raw.githubusercontent.com/nvm-sh/nvm/… | bash
目前会在自己网络会报错,可能因为github的原因,去公司网络看看;
2.在未安装node之前yarn无法直接brew install yarn安装;
报错如下:Searching for similarly named formulae...
原因未知:是否是未安装好**node**的原因呢
浏览器开启跨域:open -a /Applications/Google\ Chrome.app --args --disable-web-security --user-data-dir=/Users/mac/Documents/MyChromeDev