发布于 2026-01-06 0 阅读
0

如何在 macOS 2022 版上设置我的开发环境

如何在 macOS 2022 版上设置我的开发环境

2022年软件开发人员当前技术栈

前端:HTML、CSS、JavaScript、TypeScript、React、React Native、Redux;

后端:Python、NodeJS、C#、SQL、NoSQL、Docker

传输文件

我设置新电脑时总是倾向于全新安装系统。你可以使用云备份方案来恢复数据,或者使用外部存储设备将文件传输到新电脑。

安装网页浏览器

安装网页浏览器扩展程序(Chromium)

安装软件

我会安装所有我常用的应用,包括个人应用和开发相关的应用。不过,本指南只介绍开发相关的应用,因为它们与本指南更为相关。

安装软件包管理器

  • 自制啤酒
  • npm
  • 皮普

自制啤酒

https://brew.sh/

M1 Mac 用户
在安装 Homebrew 之前,需要先安装适用于新型 ARM 芯片(M1 芯片)的 Rosetta2 模拟器。请使用终端安装 Rosetta2:

/usr/sbin/softwareupdate --install-rosetta --agree-to-license
Enter fullscreen mode Exit fullscreen mode

使用上面的代码安装 Rosetta2 后,您就可以使用 Homebrew 命令为 ARM M1 芯片安装 Homebrew 了。

arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Enter fullscreen mode Exit fullscreen mode

安装好适用于 M1 ARM 的 Homebrew 后,使用以下 Homebrew 命令安装软件包:

arch -x86_64 brew install <package>
Enter fullscreen mode Exit fullscreen mode

安装软件包

  • Homebrew 会自动安装 Pip,并指向 Homebrew 安装的 Python 3。

使用 brew 安装以下软件包

brew install tree (It allows you to view all files in a tree view)
brew install ruby
brew install git
brew install python
brew install kotlin
brew install postgresql
brew install yarn --without-node
brew tap heroku/brew && brew install heroku
brew install deno
brew install watchman
Enter fullscreen mode Exit fullscreen mode

安装 oh-my-zsh

最新版本的 macOS 已预装 ZSH。我还安装了https://ohmyz.sh/,因为它提供了更多配置选项,在某些情况下是必需的。

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Enter fullscreen mode Exit fullscreen mode

请使用命令行显示所有隐藏文件,因为您要查找的文件默认情况下是隐藏的。

defaults write com.apple.Finder AppleShowAllFiles true
killall Finder
Enter fullscreen mode Exit fullscreen mode

请在下方安装 Oh My Zsh 插件。

brew install zsh-autosuggestions
brew install zsh-syntax-highlighting
Enter fullscreen mode Exit fullscreen mode

要激活插件,请在 .zshrc 文件末尾添加以下内容:

source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
Enter fullscreen mode Exit fullscreen mode

您还需要强制重新加载 .zshrc 文件:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

如果您收到“找不到高亮显示目录”错误消息,则可能需要将以下内容添加到您的 .zshenv 文件中:

export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters
Enter fullscreen mode Exit fullscreen mode

MongoDB 安装和设置

https://stackoverflow.com/questions/57856809/installing-mongodb-with-homebrew

1) 从https://brew.sh/#install安装 Xcode 命令行工具和 Homebrew 工具。

xcode-select --install
Enter fullscreen mode Exit fullscreen mode

2) 点击 MongoDB Homebrew Tap:

brew tap mongodb/brew
Enter fullscreen mode Exit fullscreen mode

3) 在 macOS 终端中验证安装先决条件:

brew tap | grep mongodb
Enter fullscreen mode Exit fullscreen mode

4)安装 MongoDB

brew install mongodb-community@4.4
Enter fullscreen mode Exit fullscreen mode

5) 最后,要将 MongoDB(即 mongod 进程)作为 macOS 服务运行,请执行以下命令:

brew services start mongodb-community@4.4
Enter fullscreen mode Exit fullscreen mode

6) 下载并安装 MongoDB Compass :https://www.mongodb.com/try/download/compass

使用该命令brew list查看所有已安装的软件包。

npm

通过 nvm 安装 node,因为nvm它允许您通过命令行快速安装和使用不同版本的 node。

https://github.com/nvm-sh/nvm

全局安装软件包

npm i -g @aws-amplify/cli
npm i -g @sanity/cli
npm i -g babel-cli
npm i -g eslint
npm i -g expo-cli
npm i -g firebase-tools
npm i -g gatsby-cli
npm i -g jest
npm i -g lighthouse
npm i -g netlify-cli
npm i -g newman
npm i -g node-sass
npm i -g parcel-bundler
npm i -g pm2
npm i -g prettier
npm i -g serve
npm i -g spaceship-prompt
npm i -g surge
npm i -g typescript
npm i -g update
npm i -g vercel
npm i -g yarn
Enter fullscreen mode Exit fullscreen mode

使用该命令npm list -g --depth 0查看所有已安装的软件包。

皮普

安装软件包

根据您的系统,使用pip相应的命令进行安装。pip3

pip3 install astroid
pip3 install autopep8
pip3 install certifi
pip3 install chardet2
pip3 install click
pip3 install Flask
pip3 install Flask-Cors
pip3 install harperdb
pip3 install idna
pip3 install isort
pip3 install itsdangerous
pip3 install Jinja
pip3 install lazy-object-proxy
pip3 install MarkupSafe
pip3 install mccabe
pip3 install psycopg2
pip3 install psycopg2-binary
pip3 install pycodestyle
pip3 install pylint
pip3 install python-dotenv
pip3 install requests
pip3 install setuptools
pip3 install six
pip3 install toml
pip3 install urllib3
pip3 install Werkzeug
pip3 install wrapt
Enter fullscreen mode Exit fullscreen mode

使用命令pip3 listpip list查看所有已安装的软件包

更新Python包

可以使用pip升级所有软件包:

1)将已安装软件包的列表输出到 requirements 文件(requirements.txt)中:

pip freeze > requirements.txt
Enter fullscreen mode Exit fullscreen mode

2) 编辑 requirements.txt 文件,并使用编辑器中的“全部替换”命令将所有内容替换==为所需内容。3 ) 升级所有过时的软件包:>=

pip install -r requirements.txt --upgrade
Enter fullscreen mode Exit fullscreen mode

React Native 设置

https://expo.io/

安装 BASH 应用程序、代码编辑器和 IDE

我目前在 Visual Studio Code、Visual Studio、Android Studio、PyCharm 以及 Hyper 和 iTerm 2 中都使用了Dracula主题。

字体

字体方面,我使用的是 Jebrains Mono。

https://www.jetbrains.com/lp/mono/

超级终端

安装插件并进行自定义

hyper i hypercwd
hyper i hyper-snazzy
hyper i hyper-dracula
Enter fullscreen mode Exit fullscreen mode
// default font size in pixels for all tabs
    fontSize: 16,

// font family with optional fallbacks
    fontFamily: 'JetBrains Mono, Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
Enter fullscreen mode Exit fullscreen mode

Visual Studio

下载并安装最新版本的.NET,包括 ASP.NET Core

Visual Studio Code

如果您是第一次使用 Visual Studio Code,请进行全新安装并根据需要进行配置。否则,请使用内置的设置同步功能,将之前的设置同步到新版本。

我使用的 Visual Studio Code 扩展

我目前安装了 41 个扩展程序。

美化 css/sass/scss/less
更好的注释
C#
着色
数据工作区
Docker
DotENV
Dracula 官方
EJS 语言支持
ES7+ React/Redux/React-Native 代码片段
ESLint
Excel 查看器
GitHub Pull Requests 和 Issues
GitLens — Git 增强版
HTMLHint
导入成本
Jest
Jupyter
Jupyter Keymap
Jupyter Notebook 渲染器
Live Server
markdownlint
Material 图标主题
MDX
MongoDB for VS Code
npm
npm Intellisense
在浏览器中打开
Prettier - 代码格式化程序
项目管理器
Pylance
Python
Rainbow CSV
Remote - Containers
Shades of Purple
SQL 数据库项目
SQL Server (mssql)
SVG
Thunder Client
TSLint
vscode-styled-components

文章来源:https://dev.to/andrewbaisden/how-i-setup-my-development-environment-on-macos-2022-edition-5elf