File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1105,7 +1105,36 @@ main() {
11051105 PKG_MANAGER=$( check_package_manager " $os " )
11061106
11071107 log_info " $LANG_SYSTEM_INFO : $system_info "
1108- log_info " $LANG_PACKAGE_MANAGER : $PKG_MANAGER "
1108+
1109+ # 检查并安装 npm
1110+ local display_pm=" $PKG_MANAGER "
1111+ if ! command -v npm & > /dev/null; then
1112+ log_info " npm 未安装,正在安装..."
1113+ case " $os " in
1114+ macos) brew install node ;;
1115+ linux)
1116+ case " $PKG_MANAGER " in
1117+ apt) sudo apt install -y npm ;;
1118+ dnf) sudo dnf install -y npm ;;
1119+ pacman) sudo pacman -S npm --noconfirm ;;
1120+ esac
1121+ ;;
1122+ windows)
1123+ if command -v winget & > /dev/null; then
1124+ winget install OpenJS.NodeJS --accept-package-agreements --accept-source-agreements
1125+ else
1126+ log_warn " winget 未找到,无法自动安装 npm"
1127+ fi
1128+ ;;
1129+ esac
1130+ hash -r 2> /dev/null
1131+ export PATH=" $PATH :/usr/local/bin"
1132+ fi
1133+ if command -v npm & > /dev/null; then
1134+ display_pm=" $display_pm , npm"
1135+ fi
1136+
1137+ log_info " $LANG_PACKAGE_MANAGER : $display_pm "
11091138
11101139 [[ " $os " == " unknown" ]] && log_error " $LANG_UNSUPPORTED_OS " && exit 1
11111140
Original file line number Diff line number Diff line change @@ -1105,7 +1105,36 @@ main() {
11051105 PKG_MANAGER=$( check_package_manager " $os " )
11061106
11071107 log_info " $LANG_SYSTEM_INFO : $system_info "
1108- log_info " $LANG_PACKAGE_MANAGER : $PKG_MANAGER "
1108+
1109+ # 检查并安装 npm
1110+ local display_pm=" $PKG_MANAGER "
1111+ if ! command -v npm & > /dev/null; then
1112+ log_info " npm 未安装,正在安装..."
1113+ case " $os " in
1114+ macos) brew install node ;;
1115+ linux)
1116+ case " $PKG_MANAGER " in
1117+ apt) sudo apt install -y npm ;;
1118+ dnf) sudo dnf install -y npm ;;
1119+ pacman) sudo pacman -S npm --noconfirm ;;
1120+ esac
1121+ ;;
1122+ windows)
1123+ if command -v winget & > /dev/null; then
1124+ winget install OpenJS.NodeJS --accept-package-agreements --accept-source-agreements
1125+ else
1126+ log_warn " winget 未找到,无法自动安装 npm"
1127+ fi
1128+ ;;
1129+ esac
1130+ hash -r 2> /dev/null
1131+ export PATH=" $PATH :/usr/local/bin"
1132+ fi
1133+ if command -v npm & > /dev/null; then
1134+ display_pm=" $display_pm , npm"
1135+ fi
1136+
1137+ log_info " $LANG_PACKAGE_MANAGER : $display_pm "
11091138
11101139 [[ " $os " == " unknown" ]] && log_error " $LANG_UNSUPPORTED_OS " && exit 1
11111140
You can’t perform that action at this time.
0 commit comments