mac m1 通过homebrew安装node

一、查看可安装的

brew search node

二、通过命令进行安装

        可通过@进行制定版本安装brew install node

#不指定版本安装
brew install node
# 指定版本
brew install node@版本号

三、查看当前安装的版本

#查看node版本
node -v
#查看npm版本
npm -v

四、遇到的问题:

安装node后查看node版本显示

zsh: command not found: node

五、解决过程

    方法一、卸载后重新安装

#卸载node
brew uninstall node@16
#重新安装
brew install node@16

 方法二、手动增加系统shell配置文件

  • 打开终端并编辑您的 shell 配置文件(例如 ~/.zshrc):

    vi ~/.zshrc
    
  • 在文件的末尾添加以下内容:

    export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
    
  • 保存并关闭文件,然后执行以下命令使配置文件生效:

    source ~/.zshrc
    

完美解决~

猜你喜欢

转载自blog.csdn.net/weixin_44719880/article/details/134204437