fix: resolve PAM module and npm_config_prefix issues on Ubuntu (issue 380)

This commit addresses the Ubuntu installation issues reported in issue 380:

  **PAM Module Fix:** - Fix .npmignore to include authenticate-pam module in npm package - Previously node_modules/ exclusion prevented
  authenticate-pam from being packaged - Resolves \"PAM Authentication Warning: The native authenticate-pam module isn't found\"

  **npm_config_prefix Conflict Detection:** - Add detection for npm_config_prefix conflicts with NVM in postinstall script - Warn users when
  npm_config_prefix overrides NVM's per-version configuration - Provide clear instructions to resolve the conflict - Document
  troubleshooting steps in docs/npm.md
This commit is contained in:
Alex Mazanov 2025-07-16 21:07:59 -04:00 committed by Peter Steinberger
parent a1328a90c6
commit 5fac9e5e2b
3 changed files with 52 additions and 0 deletions

View file

@ -26,6 +26,7 @@ build/
*.tmp
.DS_Store
node_modules/
!node_modules/authenticate-pam/
pnpm-lock.yaml
# Native build scripts - not needed for npm package

View file

@ -379,6 +379,41 @@ The npm package works seamlessly alongside the Mac app:
**Cause**: Network issues or unsupported platform/Node version
**Result**: Automatic fallback to source compilation
#### npm_config_prefix Conflict with NVM
**Error**: Global npm installs fail or install to wrong location when using NVM
**Symptoms**:
- `npm install -g` installs packages to system location instead of NVM directory
- Command not found errors after global install
- Permission errors during global installation
**Cause**: The `npm_config_prefix` environment variable overrides NVM's per-version npm configuration
**Detection**: VibeTunnel's postinstall script will warn if this conflict is detected:
```
⚠️ Detected npm_config_prefix conflict with NVM
npm_config_prefix: /usr/local
NVM Node path: /home/user/.nvm/versions/node/v20.19.4/bin/node
This may cause npm global installs to fail or install in wrong location.
```
**Solution**: Unset the conflicting environment variable:
```bash
unset npm_config_prefix
```
**Permanent fix**: Remove or comment out `npm_config_prefix` settings in:
- `~/.bashrc`
- `~/.bash_profile`
- `~/.profile`
- `/etc/profile`
- CI/CD environment configurations
**Common sources of this issue**:
- Previous system-wide npm installations
- Docker containers with npm pre-installed
- CI/CD environments with global npm configuration
- Package managers that set global npm prefix
### Debugging Installation
```bash
# Verbose npm install

View file

@ -12,6 +12,22 @@ const os = require('os');
console.log('Setting up native modules for VibeTunnel...');
// Check for npm_config_prefix conflict with NVM
if (process.env.npm_config_prefix && process.env.NVM_DIR) {
const nvmNodeVersion = process.execPath;
const npmPrefix = process.env.npm_config_prefix;
// Check if npm_config_prefix conflicts with NVM path
if (!nvmNodeVersion.includes(npmPrefix) && nvmNodeVersion.includes('.nvm')) {
console.warn('⚠️ Detected npm_config_prefix conflict with NVM');
console.warn(` npm_config_prefix: ${npmPrefix}`);
console.warn(` NVM Node path: ${nvmNodeVersion}`);
console.warn(' This may cause npm global installs to fail or install in wrong location.');
console.warn(' Run: unset npm_config_prefix');
console.warn(' Then reinstall VibeTunnel for proper NVM compatibility.');
}
}
// Check if we're in development (has src directory) or npm install
const isDevelopment = fs.existsSync(path.join(__dirname, '..', 'src'));