苹果电脑MacOs——nvm/node环境搭建

安装brew

tips:
https://blog.csdn.net/muyimo/article/details/125211460

1
2
// 按命令提示操作即可 
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

通过brew安装nvm

第一步

1
brew install nvm

第二步还要按照提示

1
2
3
4
5
6
7
8
9
10
11
12
13
brew info nvm // 找个命令可以从新打印出教你如何操作的提示

// 以下就是提示
You should create NVM's working directory if it doesn't exist:

mkdir ~/.nvm // ****1.shell命令行输入这个

Add the following to ~/.zshrc or your desired shell // 打开.zshrc文件把以下配置放进去(具体配置根据上面打印出的提示复制)
configuration file:

export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && . "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
  • 遇到找不到.zshrc这个文件?在根目录下确保这个文件是否存在
    1
    zsh: ~/.zshrc
  • 然后打开这个文件
    1
    open ~/.zshrc
  • 没有权限时
    1
    touch ~/.zshrc
  • 常用命令
    1
    2
    3
    4
    5
    6
    7
    8
    // 安装node版本
    nvm install 12.XX.XX
    // 查看版本列表
    nvm ls
    // 使用某个版本
    nvm use 12.XX.XX

    // 安装完毕后记得重启编辑器`npm`命令才能被识别到

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2024 HL's Blog All Rights Reserved.

UV : | PV :