# FFAIR.GIFTS Node.js Diagnostic Instructions

## For Hosting Provider Support Team

### Issue Summary
The customer is experiencing Node.js environment configuration issues where:
- NODE_PATH and NODE_MODULES_PATH environment variables are "set but ineffective"
- Node.js applications fail to start with exit code 127
- Module resolution is not working properly

### How to Run the Diagnostic Test

1. **Upload the test files** to the customer's server directory:
   - `test-nodejs.js` - The main diagnostic script
   - `run-diagnostic.sh` - Shell script to run the test

2. **Make the scripts executable**:
   ```bash
   chmod +x test-nodejs.js
   chmod +x run-diagnostic.sh
   ```

3. **Run the diagnostic test**:
   ```bash
   ./run-diagnostic.sh
   ```

   OR run directly with Node.js:
   ```bash
   node test-nodejs.js
   ```

### What the Test Checks

The diagnostic script will test:

1. **Basic Node.js functionality** - Version, platform, architecture
2. **Environment variables** - NODE_ENV, NODE_PATH, NODE_MODULES_PATH, PORT, etc.
3. **Module resolution paths** - How Node.js searches for modules
4. **File system access** - Current directory contents and permissions
5. **Package.json** - Project configuration and dependencies
6. **Node modules directory** - Whether dependencies are installed
7. **Specific path tests** - Checks the exact paths mentioned in your configuration
8. **Module loading** - Tests if Express (or other modules) can be loaded
9. **Process information** - Memory usage, user permissions
10. **Diagnostic summary** - Recommendations based on findings

### Expected Issues and Solutions

#### Issue 1: NODE_PATH "NOT SET"
**Problem**: Environment variable not being passed to Node.js process
**Solution**: Check your GUI configuration and ensure the SetEnv directive is working

#### Issue 2: "node_modules directory NOT FOUND"
**Problem**: Dependencies not installed
**Solution**: Run `npm install` in the project directory

#### Issue 3: "Failed to load Express module"
**Problem**: Module resolution not working
**Solution**: Check NODE_PATH configuration and node_modules location

#### Issue 4: Path permission errors
**Problem**: Node.js can't access required directories
**Solution**: Check file permissions and ownership

### Current Configuration (from customer)
```
SetEnv NODE_ENV production
SetEnv NODE_PATH /home/ffairgif/public_html/sandbox/node_modules
SetEnv PORT 3000
SetEnv NODE_MODULES_PATH /home/ffairgif/public_html/sandbox/node_modules
SetEnv NPM_CONFIG_PREFIX
```

### Key Questions to Answer

1. Are the environment variables actually being set in the Node.js process?
2. Does the `/home/ffairgif/public_html/sandbox/node_modules` directory exist?
3. Are the file permissions correct for the Node.js user?
4. Is the NODE_PATH being recognized by the module resolution system?

### Next Steps

1. Run the diagnostic test
2. Share the output with the customer
3. Based on the results, adjust the environment configuration
4. Test the application startup again

### Contact Information

If you need assistance interpreting the results, please provide:
- The complete output from `diagnostic-output.txt`
- Your current environment configuration
- Any error messages from the application startup

---

**Note**: This diagnostic test is designed to be safe and non-intrusive. It only reads information and doesn't modify any files or settings. 