Skip to content

Commit b31c403

Browse files
committed
fix: enforce Node.js 18.17.0+ requirement and add version validation
- Update Node.js requirement to 18.17.0+ (minimum) or 20.0.0+ (recommended LTS) - Add engines field to package.json to enforce Node.js version - Create .nvmrc file for nvm users (Node.js 20) - Update Dockerfile to use node:20-alpine - Update CI/CD workflows to use Node.js 20 - Add comprehensive Node.js version check script (check_node_version.sh) - Enhance setup_environment.sh with Node.js version validation - Update README.md and DEPLOYMENT.md with version requirements and troubleshooting - Add detailed troubleshooting section for 'Cannot find module node:path' error Fixes QA-reported issue where Node.js < 18.17.0 fails with node:path error. Users with Node.js 18.0.0-18.16.x will now get clear error messages and upgrade instructions.
1 parent 5dd6e20 commit b31c403

File tree

9 files changed

+251
-23
lines changed

9 files changed

+251
-23
lines changed

.github/workflows/ci-cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
python-version: [3.11]
25-
node-version: [18]
25+
node-version: [20]
2626

2727
steps:
2828
- name: Checkout code

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up Node.js
3030
uses: actions/setup-node@v4
3131
with:
32-
node-version: '18'
32+
node-version: '20'
3333
cache: 'npm'
3434
cache-dependency-path: package-lock.json
3535

DEPLOYMENT.md

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ Complete deployment guide for the Warehouse Operational Assistant with Docker an
2424
git clone https://github.com/T-DevH/Multi-Agent-Intelligent-Warehouse.git
2525
cd Multi-Agent-Intelligent-Warehouse
2626

27-
# 2. Setup environment
27+
# 2. Verify Node.js version (recommended before setup)
28+
./scripts/setup/check_node_version.sh
29+
30+
# 3. Setup environment
2831
./scripts/setup/setup_environment.sh
2932

30-
# 3. Configure environment variables (REQUIRED before starting services)
33+
# 4. Configure environment variables (REQUIRED before starting services)
3134
# Create .env file for Docker Compose (recommended location)
3235
cp .env.example deploy/compose/.env
3336
# Or create in project root: cp .env.example .env
3437
# Edit with your values: nano deploy/compose/.env
3538

36-
# 4. Start infrastructure services
39+
# 5. Start infrastructure services
3740
./scripts/setup/dev_up.sh
3841

39-
# 5. Run database migrations
42+
# 6. Run database migrations
4043
source env/bin/activate
4144

4245
# Option A: Using psql (requires PostgreSQL client installed)
@@ -53,19 +56,19 @@ PGPASSWORD=${POSTGRES_PASSWORD:-changeme} psql -h localhost -p 5435 -U warehouse
5356
# docker-compose -f deploy/compose/docker-compose.dev.yaml exec -T timescaledb psql -U warehouse -d warehouse < data/postgres/004_inventory_movements_schema.sql
5457
# docker-compose -f deploy/compose/docker-compose.dev.yaml exec -T timescaledb psql -U warehouse -d warehouse < scripts/setup/create_model_tracking_tables.sql
5558

56-
# 6. Create default users
59+
# 7. Create default users
5760
python scripts/setup/create_default_users.py
5861

59-
# 7. Generate demo data (optional but recommended)
62+
# 8. Generate demo data (optional but recommended)
6063
python scripts/data/quick_demo_data.py
6164

62-
# 8. Generate historical demand data for forecasting (optional, required for Forecasting page)
65+
# 9. Generate historical demand data for forecasting (optional, required for Forecasting page)
6366
python scripts/data/generate_historical_demand.py
6467

65-
# 9. Start API server
68+
# 10. Start API server
6669
./scripts/start_server.sh
6770

68-
# 10. Start frontend (in another terminal)
71+
# 11. Start frontend (in another terminal)
6972
cd src/ui/web
7073
npm install
7174
npm start
@@ -93,7 +96,10 @@ npm start
9396

9497
### Common Prerequisites
9598
- Python 3.9+ (for local development)
96-
- Node.js 18+ and npm (for frontend)
99+
- **Node.js 20.0.0+** (LTS recommended) and npm (for frontend)
100+
- **Minimum**: Node.js 18.17.0+ (required for `node:path` protocol support)
101+
- **Recommended**: Node.js 20.x LTS for best compatibility
102+
- **Note**: Node.js 18.0.0 - 18.16.x will fail with `Cannot find module 'node:path'` error during frontend build
97103
- Git
98104
- PostgreSQL client (`psql`) - Required for running database migrations
99105
- **Ubuntu/Debian**: `sudo apt-get install postgresql-client`
@@ -557,6 +563,56 @@ kubectl exec -i -n warehouse-assistant deployment/postgres -- psql -U warehouse
557563

558564
### Common Issues
559565

566+
#### Node.js Version Error: "Cannot find module 'node:path'"
567+
568+
**Symptom:**
569+
```
570+
Error: Cannot find module 'node:path'
571+
Failed to compile.
572+
[eslint] Cannot read config file
573+
```
574+
575+
**Cause:**
576+
- Node.js version is too old (below 18.17.0)
577+
- The `node:path` protocol requires Node.js 18.17.0+ or 20.0.0+
578+
579+
**Solution:**
580+
1. Check your Node.js version:
581+
```bash
582+
node --version
583+
```
584+
585+
2. If version is below 18.17.0, upgrade Node.js:
586+
```bash
587+
# Using nvm (recommended)
588+
nvm install 20
589+
nvm use 20
590+
591+
# Or download from https://nodejs.org/
592+
```
593+
594+
3. Verify the version:
595+
```bash
596+
node --version # Should show v20.x.x or v18.17.0+
597+
```
598+
599+
4. Clear node_modules and reinstall:
600+
```bash
601+
cd src/ui/web
602+
rm -rf node_modules package-lock.json
603+
npm install
604+
```
605+
606+
5. Run the version check script:
607+
```bash
608+
./scripts/setup/check_node_version.sh
609+
```
610+
611+
**Prevention:**
612+
- Always check Node.js version before starting: `./scripts/setup/check_node_version.sh`
613+
- Use `.nvmrc` file: `cd src/ui/web && nvm use`
614+
- Ensure CI/CD uses Node.js 20+
615+
560616
#### Port Already in Use
561617

562618
```bash

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# =============================================================================
55
# Frontend Build Stage
66
# =============================================================================
7-
FROM node:18-alpine AS frontend-builder
7+
FROM node:20-alpine AS frontend-builder
88

99
WORKDIR /app/src/ui/web
1010

README.md

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ For more security information, see [docs/secrets.md](docs/secrets.md) and [SECUR
179179
### Prerequisites
180180

181181
- **Python 3.9+** (check with `python3 --version`)
182-
- **Node.js 18+** and npm (check with `node --version` and `npm --version`)
182+
- **Node.js 20.0.0+** (LTS recommended) and npm (check with `node --version` and `npm --version`)
183+
- **Minimum**: Node.js 18.17.0+ (required for `node:path` protocol support)
184+
- **Recommended**: Node.js 20.x LTS for best compatibility
185+
- **Note**: Node.js 18.0.0 - 18.16.x will fail with `Cannot find module 'node:path'` error
183186
- **Docker** and Docker Compose
184187
- **Git** (to clone the repository)
185188
- **PostgreSQL client** (`psql`) - Required for running database migrations
@@ -197,19 +200,22 @@ For the fastest local development setup:
197200
git clone https://github.com/T-DevH/Multi-Agent-Intelligent-Warehouse.git
198201
cd Multi-Agent-Intelligent-Warehouse
199202

200-
# 2. Setup environment
203+
# 2. Verify Node.js version (recommended before setup)
204+
./scripts/setup/check_node_version.sh
205+
206+
# 3. Setup environment
201207
./scripts/setup/setup_environment.sh
202208

203-
# 3. Configure environment variables (REQUIRED before starting services)
209+
# 4. Configure environment variables (REQUIRED before starting services)
204210
# Create .env file for Docker Compose (recommended location)
205211
cp .env.example deploy/compose/.env
206212
# Or create in project root: cp .env.example .env
207213
# Edit with your values: nano deploy/compose/.env
208214

209-
# 4. Start infrastructure services
215+
# 5. Start infrastructure services
210216
./scripts/setup/dev_up.sh
211217

212-
# 5. Run database migrations
218+
# 6. Run database migrations
213219
source env/bin/activate
214220

215221
# Option A: Using psql (requires PostgreSQL client installed)
@@ -223,19 +229,19 @@ PGPASSWORD=${POSTGRES_PASSWORD:-changeme} psql -h localhost -p 5435 -U warehouse
223229
# docker-compose -f deploy/compose/docker-compose.dev.yaml exec -T timescaledb psql -U warehouse -d warehouse < data/postgres/000_schema.sql
224230
# (Repeat for other schema files)
225231

226-
# 6. Create default users
232+
# 7. Create default users
227233
python scripts/setup/create_default_users.py
228234

229-
# 7. Generate demo data (optional but recommended)
235+
# 8. Generate demo data (optional but recommended)
230236
python scripts/data/quick_demo_data.py
231237

232-
# 8. Generate historical demand data for forecasting (optional, required for Forecasting page)
238+
# 9. Generate historical demand data for forecasting (optional, required for Forecasting page)
233239
python scripts/data/generate_historical_demand.py
234240

235-
# 9. Start API server
241+
# 10. Start API server
236242
./scripts/start_server.sh
237243

238-
# 10. Start frontend (in another terminal)
244+
# 11. Start frontend (in another terminal)
239245
cd src/ui/web
240246
npm install
241247
npm start
@@ -289,6 +295,16 @@ python setup_nvidia_api.py
289295

290296
### Troubleshooting
291297

298+
**Node.js Version Issues:**
299+
- **Error: "Cannot find module 'node:path'"**: Your Node.js version is too old
300+
- Check version: `node --version`
301+
- Minimum required: Node.js 18.17.0+
302+
- Recommended: Node.js 20.x LTS
303+
- Run version check: `./scripts/setup/check_node_version.sh`
304+
- Upgrade: `nvm install 20 && nvm use 20` (if using nvm)
305+
- Or download from: https://nodejs.org/
306+
- After upgrading, clear and reinstall: `cd src/ui/web && rm -rf node_modules package-lock.json && npm install`
307+
292308
**Database Connection Issues:**
293309
- Ensure Docker containers are running: `docker ps`
294310
- Check TimescaleDB logs: `docker logs wosa-timescaledb`
@@ -300,6 +316,11 @@ python setup_nvidia_api.py
300316
- Use the startup script: `./scripts/start_server.sh`
301317
- See [DEPLOYMENT.md](DEPLOYMENT.md) troubleshooting section
302318

319+
**Frontend Build Issues:**
320+
- Verify Node.js version: `./scripts/setup/check_node_version.sh`
321+
- Clear node_modules: `cd src/ui/web && rm -rf node_modules package-lock.json && npm install`
322+
- Check for port conflicts: Ensure port 3001 is available
323+
303324
**For more help:** See [DEPLOYMENT.md](DEPLOYMENT.md) for detailed troubleshooting or open an issue on GitHub.
304325

305326
## Multi-Agent System
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
# Node.js version check script for Warehouse Operational Assistant
3+
# Checks if Node.js version meets minimum requirements
4+
5+
set -e
6+
7+
MIN_NODE_VERSION="18.17.0"
8+
RECOMMENDED_NODE_VERSION="20.0.0"
9+
MIN_NPM_VERSION="9.0.0"
10+
11+
echo "🔍 Checking Node.js and npm versions..."
12+
echo ""
13+
14+
# Check if Node.js is installed
15+
if ! command -v node &> /dev/null; then
16+
echo "❌ Node.js is not installed."
17+
echo " Please install Node.js $RECOMMENDED_NODE_VERSION+ (minimum: $MIN_NODE_VERSION)"
18+
echo " Download from: https://nodejs.org/"
19+
echo ""
20+
echo " Or use nvm (Node Version Manager):"
21+
echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"
22+
echo " nvm install 20"
23+
echo " nvm use 20"
24+
exit 1
25+
fi
26+
27+
# Get Node.js version
28+
NODE_VERSION=$(node --version | cut -d'v' -f2)
29+
NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d'.' -f1)
30+
NODE_MINOR=$(echo "$NODE_VERSION" | cut -d'.' -f2)
31+
NODE_PATCH=$(echo "$NODE_VERSION" | cut -d'.' -f3)
32+
33+
echo "📦 Node.js version: $NODE_VERSION"
34+
35+
# Parse minimum version for comparison
36+
MIN_MAJOR=$(echo "$MIN_NODE_VERSION" | cut -d'.' -f1)
37+
MIN_MINOR=$(echo "$MIN_NODE_VERSION" | cut -d'.' -f2)
38+
MIN_PATCH=$(echo "$MIN_NODE_VERSION" | cut -d'.' -f3)
39+
40+
# Check if version meets minimum requirements
41+
VERSION_OK=false
42+
if [ "$NODE_MAJOR" -gt "$MIN_MAJOR" ]; then
43+
VERSION_OK=true
44+
elif [ "$NODE_MAJOR" -eq "$MIN_MAJOR" ]; then
45+
if [ "$NODE_MINOR" -gt "$MIN_MINOR" ]; then
46+
VERSION_OK=true
47+
elif [ "$NODE_MINOR" -eq "$MIN_MINOR" ]; then
48+
if [ "$NODE_PATCH" -ge "$MIN_PATCH" ]; then
49+
VERSION_OK=true
50+
fi
51+
fi
52+
fi
53+
54+
if [ "$VERSION_OK" = false ]; then
55+
echo "❌ Node.js version $NODE_VERSION is too old."
56+
echo " Minimum required: $MIN_NODE_VERSION"
57+
echo " Recommended: $RECOMMENDED_NODE_VERSION+ (LTS)"
58+
echo ""
59+
echo " Note: Node.js 18.0.0 - 18.16.x will fail with 'Cannot find module node:path' error"
60+
echo ""
61+
echo " Upgrade options:"
62+
echo " 1. Download from: https://nodejs.org/"
63+
echo " 2. Use nvm: nvm install 20 && nvm use 20"
64+
exit 1
65+
fi
66+
67+
# Check if version is recommended
68+
if [ "$NODE_MAJOR" -lt 20 ]; then
69+
echo "⚠️ Node.js 18.17.0+ detected. Node.js 20.x LTS is recommended for best compatibility."
70+
else
71+
echo "✅ Node.js version meets requirements (20.x LTS)"
72+
fi
73+
74+
# Check npm version
75+
if ! command -v npm &> /dev/null; then
76+
echo "⚠️ npm is not installed. Please install npm $MIN_NPM_VERSION+"
77+
exit 1
78+
fi
79+
80+
NPM_VERSION=$(npm --version)
81+
echo "📦 npm version: $NPM_VERSION"
82+
83+
# Check npm version meets minimum
84+
NPM_MAJOR=$(echo "$NPM_VERSION" | cut -d'.' -f1)
85+
MIN_NPM_MAJOR=$(echo "$MIN_NPM_VERSION" | cut -d'.' -f1)
86+
87+
if [ "$NPM_MAJOR" -lt "$MIN_NPM_MAJOR" ]; then
88+
echo "⚠️ npm version $NPM_VERSION is below recommended minimum ($MIN_NPM_VERSION)"
89+
echo " Consider upgrading: npm install -g npm@latest"
90+
else
91+
echo "✅ npm version meets requirements"
92+
fi
93+
94+
echo ""
95+
echo "✅ Node.js and npm version check passed!"
96+
echo ""
97+
98+
# Check for .nvmrc file and suggest using it
99+
if [ -f "src/ui/web/.nvmrc" ]; then
100+
NVMRC_VERSION=$(cat src/ui/web/.nvmrc)
101+
echo "💡 Tip: This project uses Node.js $NVMRC_VERSION (see src/ui/web/.nvmrc)"
102+
echo " If using nvm, run: cd src/ui/web && nvm use"
103+
fi
104+

scripts/setup/setup_environment.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,48 @@ fi
2121
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
2222
echo "✅ Found Python $PYTHON_VERSION"
2323

24+
# Check Node.js version
25+
if ! command -v node &> /dev/null; then
26+
echo "❌ Node.js is not installed. Please install Node.js 20.0.0+ (or minimum 18.17.0+) first."
27+
echo " Recommended: Node.js 20.x LTS"
28+
exit 1
29+
fi
30+
31+
NODE_VERSION=$(node --version | cut -d'v' -f2)
32+
NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d'.' -f1)
33+
NODE_MINOR=$(echo "$NODE_VERSION" | cut -d'.' -f2)
34+
NODE_PATCH=$(echo "$NODE_VERSION" | cut -d'.' -f3)
35+
36+
echo "✅ Found Node.js $NODE_VERSION"
37+
38+
# Check if Node.js version meets requirements
39+
# Minimum: 18.17.0, Recommended: 20.0.0+
40+
if [ "$NODE_MAJOR" -lt 18 ]; then
41+
echo "❌ Node.js version $NODE_VERSION is too old. Please install Node.js 18.17.0+ (recommended: 20.x LTS)"
42+
exit 1
43+
elif [ "$NODE_MAJOR" -eq 18 ]; then
44+
if [ "$NODE_MINOR" -lt 17 ]; then
45+
echo "❌ Node.js version $NODE_VERSION is too old. Please install Node.js 18.17.0+ (recommended: 20.x LTS)"
46+
echo " Note: Node.js 18.0.0 - 18.16.x will fail with 'Cannot find module node:path' error"
47+
exit 1
48+
elif [ "$NODE_MINOR" -eq 17 ] && [ "$NODE_PATCH" -lt 0 ]; then
49+
echo "❌ Node.js version $NODE_VERSION is too old. Please install Node.js 18.17.0+ (recommended: 20.x LTS)"
50+
exit 1
51+
else
52+
echo "⚠️ Node.js 18.17.0+ detected. Node.js 20.x LTS is recommended for best compatibility."
53+
fi
54+
elif [ "$NODE_MAJOR" -ge 20 ]; then
55+
echo "✅ Node.js version meets requirements (20.x LTS recommended)"
56+
fi
57+
58+
# Check npm version
59+
if ! command -v npm &> /dev/null; then
60+
echo "⚠️ npm is not installed. Please install npm 9.0.0+"
61+
else
62+
NPM_VERSION=$(npm --version)
63+
echo "✅ Found npm $NPM_VERSION"
64+
fi
65+
2466
# Create virtual environment if it doesn't exist
2567
if [ ! -d "env" ]; then
2668
echo "📦 Creating virtual environment..."

src/ui/web/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

0 commit comments

Comments
 (0)