From 5951638967e42780d0255c9bee168ce266087c1c Mon Sep 17 00:00:00 2001 From: Philipp Kunz <code@philkunz.com> Date: Wed, 26 Mar 2025 13:51:45 +0000 Subject: [PATCH] fix(setup): Update setup.sh to temporarily add vendor Node.js binary to PATH for dependency installation, log Node and npm versions, and restore the original PATH afterwards. --- changelog.md | 7 +++++++ setup.sh | 16 ++++++++++++++-- ts/00_commitinfo_data.ts | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 2b64347..cc7d1b8 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-03-26 - 2.6.1 - fix(setup) +Update setup.sh to temporarily add vendor Node.js binary to PATH for dependency installation, log Node and npm versions, and restore the original PATH afterwards. + +- Temporarily prepend vendor Node.js binary directory to PATH to ensure proper npm execution. +- Log Node.js and npm versions for debugging purposes. +- Restore the original PATH after installing dependencies. + ## 2025-03-26 - 2.6.0 - feat(setup) Add --force update flag to setup script and update installation instructions diff --git a/setup.sh b/setup.sh index 1bf1fc5..b7a12eb 100644 --- a/setup.sh +++ b/setup.sh @@ -239,13 +239,22 @@ echo "dist_ts directory successfully downloaded from npm registry." # Make launcher script executable chmod +x "$SCRIPT_DIR/bin/nupst" +# Add our Node.js bin directory to the PATH temporarily +NODE_BIN_DIR="$SCRIPT_DIR/vendor/$NODE_DIR/bin" +OLD_PATH="$PATH" +export PATH="$NODE_BIN_DIR:$PATH" + # Install production dependencies echo "Installing production dependencies..." -"$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund +echo "Using Node.js binary from: $NODE_BIN_DIR" +echo "Node version: $(node --version)" +echo "NPM version: $(npm --version)" + +npm --prefix "$SCRIPT_DIR" ci --only=production --no-audit --no-fund if [ $? -ne 0 ]; then echo "Warning: Failed to install dependencies with 'npm ci'. Trying 'npm install'..." - "$SCRIPT_DIR/vendor/$NODE_DIR/bin/npm" --prefix "$SCRIPT_DIR" install --only=production --no-audit --no-fund + npm --prefix "$SCRIPT_DIR" install --only=production --no-audit --no-fund if [ $? -ne 0 ]; then echo "Error: Failed to install dependencies. NUPST may not function correctly." @@ -258,6 +267,9 @@ else echo "Dependencies installed successfully with 'npm ci'." fi +# Restore the original PATH +export PATH="$OLD_PATH" + echo "NUPST setup completed successfully." echo "You can now run NUPST using: $SCRIPT_DIR/bin/nupst" echo "To install NUPST globally, run: sudo ln -s $SCRIPT_DIR/bin/nupst /usr/local/bin/nupst" diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index f0b02c9..adc14bd 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@serve.zone/nupst', - version: '2.6.0', + version: '2.6.1', description: 'Node.js UPS Shutdown Tool for SNMP-enabled UPS devices' }