-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_node.sh
More file actions
executable file
·70 lines (55 loc) · 1.74 KB
/
install_node.sh
File metadata and controls
executable file
·70 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -e
OS="$(uname -s)"
case "$OS" in
Linux*)
echo "🐧 Detected Linux system"
# Check if nvm is installed
if [ -s "$HOME/.nvm/nvm.sh" ]; then
. "$HOME/.nvm/nvm.sh"
else
echo "📦 Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
fi
echo "📦 Installing Node.js LTS via nvm..."
nvm install --lts
nvm use --lts
nvm alias default lts/*
echo "✅ Node.js $(node --version) installed"
echo "✅ npm $(npm --version) installed"
;;
Darwin*)
echo "🍎 Detected macOS system"
# Check if Homebrew is installed
if ! command -v brew &> /dev/null; then
echo "❌ Homebrew is required but not installed."
echo "Install it from https://brew.sh/"
exit 1
fi
echo "📦 Installing Node.js via Homebrew..."
brew install node
# Install watchman for React Native development
if [ "$1" == "--with-watchman" ]; then
echo "📦 Installing watchman..."
brew install watchman
fi
echo "✅ Node.js $(node --version) installed"
echo "✅ npm $(npm --version) installed"
;;
*)
echo "❌ Unsupported operating system: $OS"
exit 1
;;
esac
# Verify installation
if ! command -v node &> /dev/null; then
echo "❌ Node.js installation failed"
exit 1
fi
if ! command -v npm &> /dev/null; then
echo "❌ npm installation failed"
exit 1
fi
echo "🎉 Node.js and npm successfully installed!"