Update install-gui.sh to use check Node 18 and npm 9 (#16424)

* Update to use node 18 and npm 9

* `$(npm bin)` -> `$(npm prefix)/bin`

* `$(npm bin)` -> `$(npm prefix)/node_modules/.bin`

* Upgraded package-lock version

* `start-gui.sh` now requires npm >= 9

* Reverted `package-lock.json` version for old NodeJS/npm

---------

Co-authored-by: ChiaMineJP <admin@chiamine.jp>
This commit is contained in:
Jeff 2023-09-26 15:30:43 -07:00 committed by GitHub
parent 58ad8b8f09
commit 8b4b2ca869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -37,17 +37,17 @@ do_install_npm_locally(){
NODEJS_VERSION="$(node -v | cut -d'.' -f 1 | sed -e 's/^v//')"
NPM_VERSION="$(npm -v | cut -d'.' -f 1)"
if [ "$NODEJS_VERSION" -lt "16" ] || [ "$NPM_VERSION" -lt "7" ]; then
if [ "$NODEJS_VERSION" -lt "16" ]; then
echo "Current NodeJS version($(node -v)) is less than 16. GUI app requires NodeJS>=16."
if [ "$NODEJS_VERSION" -lt "18" ] || [ "$NPM_VERSION" -lt "9" ]; then
if [ "$NODEJS_VERSION" -lt "18" ]; then
echo "Current NodeJS version($(node -v)) is less than 18. GUI app requires NodeJS>=18."
fi
if [ "$NPM_VERSION" -lt "7" ]; then
echo "Current npm version($(npm -v)) is less than 7. GUI app requires npm>=7."
if [ "$NPM_VERSION" -lt "9" ]; then
echo "Current npm version($(npm -v)) is less than 9. GUI app requires npm>=9."
fi
if [ "$(uname)" = "OpenBSD" ] || [ "$(uname)" = "FreeBSD" ]; then
# `n` package does not support OpenBSD/FreeBSD
echo "Please install NodeJS>=16 and/or npm>=7 manually"
echo "Please install NodeJS>=18 and/or npm>=9 manually"
exit 1
fi
@ -65,19 +65,19 @@ do_install_npm_locally(){
npm ci
fi
export N_PREFIX=${SCRIPT_DIR}/.n
PATH="${N_PREFIX}/bin:$(npm bin):${PATH}"
PATH="${N_PREFIX}/bin:$(npm prefix)/node_modules/.bin:${PATH}"
export PATH
# `n 16` here installs nodejs@16 under $N_PREFIX directory
echo "n 16"
n 16
# `n 18` here installs nodejs@18 under $N_PREFIX directory
echo "n 18"
n 18
echo "Current NodeJS version: $(node -v)"
echo "Current npm version: $(npm -v)"
if [ "$(node -v | cut -d'.' -f 1 | sed -e 's/^v//')" -lt "16" ]; then
echo "Error: Failed to install NodeJS>=16"
if [ "$(node -v | cut -d'.' -f 1 | sed -e 's/^v//')" -lt "18" ]; then
echo "Error: Failed to install NodeJS>=18"
exit 1
fi
if [ "$(npm -v | cut -d'.' -f 1)" -lt "7" ]; then
echo "Error: Failed to install npm>=7"
if [ "$(npm -v | cut -d'.' -f 1)" -lt "9" ]; then
echo "Error: Failed to install npm>=9"
exit 1
fi
cd "${SCRIPT_DIR}"

View File

@ -29,8 +29,8 @@ if ! npm version >/dev/null 2>&1; then
fi
NPM_VERSION="$(npm -v | cut -d'.' -f 1)"
if [ "$NPM_VERSION" -lt "7" ]; then
echo "Current npm version($(npm -v)) is less than 7. GUI app requires npm>=7."
if [ "$NPM_VERSION" -lt "9" ]; then
echo "Current npm version($(npm -v)) is less than 9. GUI app requires npm>=9."
exit 1
else
echo "Found npm $(npm -v)"