Skip to content

Commit

Permalink
Use node version set inside . nvmrc file
Browse files Browse the repository at this point in the history
  • Loading branch information
matjazv committed Aug 14, 2024
1 parent d2dd481 commit a022cfa
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions scripts/installDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ apt update
echo "Current DIR: $PWD"
# Script to install Node.js using NVM on Ubuntu

node_version=v20
# Read node version from .nvmrc file
node_version=$(cat .nvmrc | tr -d "\n")

# Function to install NVM
install_nvm() {
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Expand All @@ -19,23 +21,16 @@ install_node_version() {
if [ -s "$nvm_path" ];
then
echo "NVM is already installed."
source $nvm_path
else
echo "Installing NVM..."
install_nvm
source nvm_path
fi

node_command=`command -v node`
current_node_version=`node -v | awk -F\. '{print $1}'`
# Check if correct version of node is present
if [[ "$node_command" ]] && [[ "$node_version" == "$current_node_version" ]];
then
echo "Correct node version is already installed."
else
echo "Node version $node_version is not installed. Installing..."
nvm install $node_version
nvm use $node_version
source $nvm_path
fi

echo "Installing Node version $node_version..."
nvm install $node_version
nvm use $node_version
}

install_node_version
Expand Down

0 comments on commit a022cfa

Please sign in to comment.