Ambari Web本地启动
# 05-ambari-web如何本地启动
# 1、准备阶段
# 1.1 Node Version Manager (nvm) 安装
在本地启动 Ambari Web 时,首先需要确保 Node.js 的版本管理。nvm
(Node Version Manager) 是一个非常有用的工具,它允许你在同一台机器上管理多个 Node.js 版本。
# 1.1.1 Windows 版本
Windows 用户需要安装 nvm-windows
。你可以通过以下链接下载和安装:
# 仓库地址
https://github.com/coreybutler/nvm-windows
# windows 下载地址
https://ghfast.top/https://github.com/coreybutler/nvm-windows/releases/download/1.1.12/nvm-noinstall.zip
1
2
3
4
2
3
4
# 1.1.2 Linux / Mac 版本
对于 Linux 或 Mac 用户,你可以直接通过 curl
或 wget
安装 nvm
。
# linux 或 mac 仓库地址
https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
1
2
3
4
5
2
3
4
5
# 1.2 nvm 使用
安装完成后,你可以配置 nvm
下载的源来加速下载过程,使用国内的镜像源来提高效率。
# 设置 nvm 下载源
setx NVM_NODEJS_ORG_MIRROR https://npmmirror.com/mirrors/node/
setx NVM_NPM_MIRROR https://npmmirror.com/mirrors/npm/
1
2
3
2
3
# 1.3 更新代码
在安装了 nvm
后,你可以切换 Node.js 的版本并更新项目的依赖。以下是更新依赖的步骤:
nvm use 16 # 切换到 Node.js 16 版本
nvm use 18 # 或切换到 Node.js 18 版本
# 安装依赖更新插件
npm install -g npm-check-updates --registry=https://registry.npmmirror.com --verbose
# 更新依赖
ncu -u --registry=https://registry.npmmirror.com --verbose
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
使用 yarn 初始化并运行本地环境
yarn run start
1
# 使用 Yarn 更新依赖
# 运行 Yarn
yarn install --ignore-engines --verbose
yarn install --registry=https://registry.npmmirror.com --verbose --ignore-engines --pure-lockfile
1
2
3
2
3
注意: 修改
package.json
中的 Node 版本为 >=4 版本即可。
# 1.4 环境准备
# Node 低版本与 Yarn 版本
对于较低版本的 Node.js(如 v4.9.1),请确保使用兼容的 Yarn 版本:
nvm use 4
npm config set registry https://registry.npmmirror.com
npm install -g yarn@v0.23.2 --verbose
npm install -g brunch --verbose
# 配置 yarn 镜像源
yarn config set registry https://registry.npmmirror.com
1
2
3
4
5
6
7
2
3
4
5
6
7
# Node 高版本与 Yarn 版本
对于较高版本的 Node.js(如 v16),可以使用 Yarn 1.22.10,并确保更新 package.json
中的 node
字段:
nvm use 16
npm config set registry https://registry.npmmirror.com
npm install -g yarn --verbose
npm install -g brunch --verbose
# 配置 yarn 镜像源
yarn config set registry https://registry.npmmirror.com
1
2
3
4
5
6
7
2
3
4
5
6
7
运行命令:
yarn run start
1
# 1.5 启动环境
最后,完成所有配置后,可以启动 Ambari Web 环境:
npm run start
1
# 启动成功
一旦启动完成,你应该能够看到如图所示的本地运行界面。