|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +# MCP Agents Hub - Environment Setup Script |
| 5 | +# This script ensures the correct Node.js version is being used via nvm |
| 6 | + |
| 7 | +echo "🚀 Setting up MCP Agents Hub development environment..." |
| 8 | + |
| 9 | +# Source nvm (in case it's not in the current shell) |
| 10 | +export NVM_DIR="$HOME/.nvm" |
| 11 | +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" |
| 12 | +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" |
| 13 | + |
| 14 | +# Check if nvm is available |
| 15 | +if ! type nvm &> /dev/null; then |
| 16 | + echo "❌ nvm is not installed or not sourced. Please install nvm first:" |
| 17 | + echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash" |
| 18 | + echo " source ~/.bashrc" |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +# Use the Node.js version specified in .nvmrc |
| 23 | +if [ -f ".nvmrc" ]; then |
| 24 | + echo "📋 Found .nvmrc file, using specified Node.js version..." |
| 25 | + nvm use |
| 26 | + if [ $? -ne 0 ]; then |
| 27 | + echo "⚠️ Node.js version not installed. Installing now..." |
| 28 | + nvm install |
| 29 | + nvm use |
| 30 | + fi |
| 31 | +else |
| 32 | + echo "⚠️ No .nvmrc file found, using default Node.js version" |
| 33 | +fi |
| 34 | + |
| 35 | +# Display current versions |
| 36 | +echo "✅ Node.js version: $(node --version)" |
| 37 | +echo "✅ npm version: $(npm --version)" |
| 38 | + |
| 39 | +# Install dependencies |
| 40 | +echo "📦 Installing dependencies..." |
| 41 | +npm ci |
| 42 | + |
| 43 | +echo "🎉 Setup complete! You can now run:" |
| 44 | +echo " npm run dev (start development server)" |
| 45 | +echo " npm run build (build for production)" |
| 46 | +echo " npm run lint (run linting)" |
0 commit comments