Skip to content

Commit cec14b7

Browse files
Chris KhanChris Khan
authored andcommitted
fix: improve Node.js version detection in setup.sh and add .nvmrc
- Load nvm at the start of setup.sh to ensure correct Node version is detected - Set Node.js v20 as default when installing via nvm - Add .nvmrc file to automatically use Node.js v20 for this project - Prevents issues with wrong Node version being detected
1 parent e18049c commit cec14b7

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

.nvmrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
20
2-

setup.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ print_info() {
2828
echo -e "${YELLOW}${NC} $1"
2929
}
3030

31+
# Load nvm if available
32+
if [ -f "$HOME/.nvm/nvm.sh" ]; then
33+
source "$HOME/.nvm/nvm.sh"
34+
fi
35+
3136
# Check if Node.js 20 is installed
3237
print_info "Checking Node.js version..."
3338
if command -v node &> /dev/null; then
@@ -39,10 +44,11 @@ if command -v node &> /dev/null; then
3944
print_info "Installing Node.js 20..."
4045

4146
# Try to install via nvm if available
42-
if command -v nvm &> /dev/null; then
47+
if [ -f "$HOME/.nvm/nvm.sh" ]; then
4348
nvm install 20
4449
nvm use 20
45-
print_success "Node.js 20 installed via nvm!"
50+
nvm alias default 20
51+
print_success "Node.js 20 installed via nvm and set as default!"
4652
else
4753
print_error "Please install Node.js 20 manually from https://nodejs.org/"
4854
print_info "Or install nvm first: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"
@@ -58,7 +64,8 @@ else
5864
source "$HOME/.nvm/nvm.sh"
5965
nvm install 20
6066
nvm use 20
61-
print_success "Node.js 20 installed via nvm!"
67+
nvm alias default 20
68+
print_success "Node.js 20 installed via nvm and set as default!"
6269
else
6370
print_error "Please install Node.js 20 first!"
6471
print_info "Easiest way: Install nvm and run this script again"

0 commit comments

Comments
 (0)