【Mac】brew、node等环境搭建

一.安装brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

遇到源问题安装不了,参考:
https://www.jianshu.com/p/e0471aa6672d?utm_campaign=hugo
https://www.jianshu.com/p/ed35ce1981e8

安装过程记录:

lsan@lichaodeMacBook-Pro-2021 ~ % ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"       
Warning: Ruby版本Homebrew安装脚本已被废弃,新版脚本使用Bash重写。
请使用以下命令:
  /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"

==> Checking for `sudo` access (which may request your password).
Password:
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
==> 安装提示
中文安装教程(建议收藏):https://brew.idayer.com/
如果你想换源,可以使用镜像助手:https://brew.idayer.com/guide/change-source/

安装遇到问题,可以通过讨论群寻求帮助。
也欢迎加群讨论,扫码关注公众号(湖中剑),回复'brew'加入讨论群。

█████████████████████████████████████
█████████████████████████████████████
████ ▄▄▄▄▄ █▀█ █▄▀▄ ▄ ▄▄██ ▄▄▄▄▄ ████
████ █   █ █▀▀▀█ ▀█▀▀▀▀▄▀█ █   █ ████
████ █▄▄▄█ █▀ █▀▀█▄▀ █▀▄ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄▀ ▀▄█▄▀ █▄▀ █▄▄▄▄▄▄▄████
████     ▀▄▄▄▄▀▄▀▄▄█▀▀█ █ ▀ ▀▄█▄▀████
████ ▀█▄▀▀▄  █▄█▀█ ▄██ █ ▀ ▄▄██▀█████
████ █   █▄ ▄ ▄█▄ ▀  ██ ▀ ▀▀▀▄ █▀████
████ ██▄██▄▀ █  ▄█▀ ▄▄▀▀ ▀ █▄█▄▀█████
████ ▄ ▀▄▄▄▀█▄ ▄▀     ▀ ▀█▀ ▀▀ █▀████
████ █ ▀▀▀▄█▄█▄█▀█▀▄ █▀▀▄▄█▄▄▄▄▀█████
████▄██▄▄█▄█▀▀▀█▄█▄ ▀▄▀█ ▄▄▄ ▀   ████
████ ▄▄▄▄▄ █▄▀  ▄█▄  ▄▀  █▄█  ▄▀█████
████ █   █ █ ▀▄▄ ▀▄ ▀███ ▄▄▄▄ ▄▀ ████
████ █▄▄▄█ █ ▄▄▀ ██▄▀▄▀▄ ▀▄   ▄ █████
████▄▄▄▄▄▄▄█▄▄█▄▄████▄█████▄▄█▄██████
█████████████████████████████████████
█████████████████████████████████████


请按回车键(RETURN)继续安装,按其他任意按键取消安装
==> /usr/bin/sudo /usr/sbin/chown -R lsan:admin /opt/homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 7531, done.
remote: Counting objects: 100% (7531/7531), done.
remote: Compressing objects: 100% (1581/1581), done.
remote: Total 7531 (delta 5798), reused 7531 (delta 5798)
Receiving objects: 100% (7531/7531), 1.61 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (5798/5798), completed with 737 local objects.
From https://mirrors.ustc.edu.cn/brew
 * [new tag]             1.1.0.1                           -> 1.1.0.1
 * [new tag]             1.1.2.1                           -> 1.1.2.1
 * [new tag]             1.2.7                             -> 1.2.7
 * [new tag]             1.2.8                             -> 1.2.8
 * [new tag]             backup/activesupport-23-38-09     -> backup/activesupport-23-38-09
 * [new tag]             backup/brew-cask-style-14-54-55   -> backup/brew-cask-style-14-54-55
 * [new tag]             backup/create-cache-00-29-47      -> backup/create-cache-00-29-47
 * [new tag]             backup/days-03-02-52              -> backup/days-03-02-52
 * [new tag]             backup/days-03-02-59              -> backup/days-03-02-59
 * [new tag]             backup/days-19-30-23              -> backup/days-19-30-23
 * [new tag]             backup/gpg-verification-01-53-16  -> backup/gpg-verification-01-53-16
 * [new tag]             backup/remove-popen-read-19-56-50 -> backup/remove-popen-read-19-56-50
 * [new tag]             backup/remove-popen-read-20-00-21 -> backup/remove-popen-read-20-00-21
HEAD is now at fa4f239cd Merge pull request #12496 from dduugg/yard-tag-cleanup
==> Tapping homebrew/core
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 1101592 (delta 18), reused 0 (delta 0)
Receiving objects: 100% (1101592/1101592), 452.62 MiB | 2.07 MiB/s, done.
Resolving deltas: 100% (765843/765843), done.
From https://mirrors.ustc.edu.cn/homebrew-core
 * [new branch]      master     -> origin/master
HEAD is now at 392884bcaa0 fortio: update 1.19.0 bottle.
HOMEBREW_BREW_GIT_REMOTE set: using https://mirrors.ustc.edu.cn/brew.git for Homebrew/brew Git remote.
HOMEBREW_CORE_GIT_REMOTE set: using https://mirrors.ustc.edu.cn/homebrew-core.git for Homebrew/core Git remote.
Warning: !!!!!!!!!!! 重要  !!!!!!!!!!!!!!!
Warning: 看到此提示,一定要执行 Next steps 中的 环境变量设置!!!
Warning: /opt/homebrew/bin is not in your PATH.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this `install` run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
Warning: !!!!!!!!!!! 重要  !!!!!!!!!!!!!!!
切记执行环境变量设置!,如已执行过请忽略。
- 执行下面命令将 Homebrew 到 PATH 中:
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/lsan/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
  如有疑问,可以访问 https://brew.idayer.com/guide/m1/
-  恭喜,安装成功!运行 `brew help` 开始体验吧
- 更多文档: 
    https://docs.brew.sh
    https://brew.idayer.com
lsan@lichaodeMacBook-Pro-2021 ~ % echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/lsan/.zprofile
lsan@lichaodeMacBook-Pro-2021 ~ % eval "$(/opt/homebrew/bin/brew shellenv)"
lsan@lichaodeMacBook-Pro-2021 ~ % 

二.安装node、npm

brew install node

四.安装jdk

1.到官网下载jdk8
https://www.oracle.com/java/technologies/downloads/#java8

2.安装后,查看jdk路径/usr/libexec/java_home -V
3.配置环境变量

vim .bash_profile

在最后一行添加

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home

wq保存后即可


vim ~/.bash_profile

在最后一行添加

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
export CLASS_PATH=$JAVA_HOME/lib
source ~/.bash_profile

五.安装mvn

1.到官网下载bin包
http://maven.apache.org/download.cgi

2.解压到自己想放的本地路径,这里使用/usr/local/
3.配置环境变量

vi ~/.bash_profile

添加:

export MAVEN_HOME=/usr/local/apache-maven-3.8.4
export PATH=$PATH:$MAVEN_HOME/bin

wq保存后,使其生效

source ~/.bash_profile

你可能感兴趣的:(【Mac】brew、node等环境搭建)