From 0b48a077381bafaccb125a505d00cd4623e01b99 Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Thu, 5 Jun 2025 03:01:20 +0000 Subject: [PATCH 1/2] feat: Enhance project setup with nvm instructions and add setup script for easier environment configuration --- .nvmrc | 1 + README.md | 35 ++++++++++++++++++++++++++++++++++- client/.nvmrc | 1 + package-lock.json | 1 + package.json | 1 + server/.nvmrc | 1 + setup.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 .nvmrc create mode 100644 client/.nvmrc create mode 100644 server/.nvmrc create mode 100755 setup.sh diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..5b540673 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22.16.0 diff --git a/README.md b/README.md index 0ff88f71..d85155a7 100644 --- a/README.md +++ b/README.md @@ -119,10 +119,43 @@ graph TD - Lucide React (for icons) ## Installation + +### Prerequisites +This project uses Node Version Manager (nvm) to manage Node.js versions. Make sure you have nvm installed globally. + +#### Installing nvm (if not already installed) +```bash +# Install nvm +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + +# Reload your shell configuration +source ~/.bashrc + +# Verify nvm installation +nvm --version +``` + +### Project Setup 1. Clone the repository -2. Run `npm install` to install dependencies +2. **Quick Setup (Recommended)**: Run the setup script which handles nvm and dependencies: + ```bash + ./setup.sh + ``` + + **OR Manual Setup**: + - Use the correct Node.js version specified in `.nvmrc`: + ```bash + nvm use + ``` + If the Node.js version isn't installed, nvm will prompt you to install it: + ```bash + nvm install + ``` + - Run `npm install` to install dependencies 3. Start the development server with `npm run dev` +**Note**: The project includes a `.nvmrc` file that specifies the required Node.js version (22.16.0). Always run `nvm use` when switching to this project to ensure you're using the correct Node.js version. + ## Available Scripts - `dev`: Start development server - `build`: Build for production diff --git a/client/.nvmrc b/client/.nvmrc new file mode 100644 index 00000000..5b540673 --- /dev/null +++ b/client/.nvmrc @@ -0,0 +1 @@ +22.16.0 diff --git a/package-lock.json b/package-lock.json index ed3f35c2..df48f5de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "mcp-marketplace", "version": "0.0.0", + "hasInstallScript": true, "workspaces": [ "client", "server" diff --git a/package.json b/package.json index 6d008603..355692e4 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "server" ], "scripts": { + "preinstall": "echo 'Make sure to run \"nvm use\" before installing dependencies'", "dev": "concurrently \"npm run server:dev\" \"npm run client:dev\"", "client:dev": "cd client && vite", "server:dev": "cd server && tsx watch src/server.ts", diff --git a/server/.nvmrc b/server/.nvmrc new file mode 100644 index 00000000..5b540673 --- /dev/null +++ b/server/.nvmrc @@ -0,0 +1 @@ +22.16.0 diff --git a/setup.sh b/setup.sh new file mode 100755 index 00000000..76acf279 --- /dev/null +++ b/setup.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# MCP Agents Hub - Environment Setup Script +# This script ensures the correct Node.js version is being used via nvm + +echo "🚀 Setting up MCP Agents Hub development environment..." + +# Source nvm (in case it's not in the current shell) +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + +# Check if nvm is available +if ! type nvm &> /dev/null; then + echo "❌ nvm is not installed or not sourced. Please install nvm first:" + echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash" + echo " source ~/.bashrc" + exit 1 +fi + +# Use the Node.js version specified in .nvmrc +if [ -f ".nvmrc" ]; then + echo "📋 Found .nvmrc file, using specified Node.js version..." + nvm use + if [ $? -ne 0 ]; then + echo "⚠️ Node.js version not installed. Installing now..." + nvm install + nvm use + fi +else + echo "⚠️ No .nvmrc file found, using default Node.js version" +fi + +# Display current versions +echo "✅ Node.js version: $(node --version)" +echo "✅ npm version: $(npm --version)" + +# Install dependencies +echo "📦 Installing dependencies..." +npm install + +echo "🎉 Setup complete! You can now run:" +echo " npm run dev (start development server)" +echo " npm run build (build for production)" +echo " npm run lint (run linting)" From 87182e22120cecb006dc4f8879be9dd43f7cf4cc Mon Sep 17 00:00:00 2001 From: Lei Xu Date: Thu, 5 Jun 2025 03:26:03 +0000 Subject: [PATCH 2/2] fix: Ensure script exits on error and use npm ci for consistent dependency installation --- setup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 76acf279..3b1f8157 100755 --- a/setup.sh +++ b/setup.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e # MCP Agents Hub - Environment Setup Script # This script ensures the correct Node.js version is being used via nvm @@ -37,7 +38,7 @@ echo "✅ npm version: $(npm --version)" # Install dependencies echo "📦 Installing dependencies..." -npm install +npm ci echo "🎉 Setup complete! You can now run:" echo " npm run dev (start development server)"