NPM Publishing Guide for VibeTunnel
Installation Guide
Installing VibeTunnel from NPM
VibeTunnel is published as an npm package that works on macOS and Linux. The package includes prebuilt binaries for common platforms to avoid compilation.Basic Installation
Platform-Specific Notes
macOS:- Works out of the box
- PAM authentication supported natively
- Works without additional dependencies
- PAM authentication is optional - installs only if PAM headers are available
- If you need PAM authentication, install development headers first:
Verifying Installation
Docker Installation
For containerized environments:Troubleshooting Installation
-
“Cannot find module ’../build/Release/pty.node’”
- The package includes prebuilds, this shouldn’t happen
- Try reinstalling:
npm uninstall -g vibetunnel && npm install -g vibetunnel
-
PAM authentication not working on Linux
- Install PAM headers:
sudo apt-get install libpam0g-dev
- Reinstall VibeTunnel to compile the PAM module
- Install PAM headers:
-
Permission errors during installation
- Use a Node.js version manager (nvm, fnm) instead of system Node.js
- Or fix npm permissions: https://docs.npmjs.com/resolving-eacces-permissions-errors
Quick Release Checklist
-
Update versions in all 3 files:
package.json
package.npm.json
../mac/VibeTunnel/version.xcconfig
-
Build:
pnpm run build:npm
-
Verify:
-
Publish tarball:
npm publish
without the tarball filename!
Critical Issue History: Wrong package.json Used in Releases
The Problem
We’ve repeatedly published npm packages with the wrong configuration:- Version 11.2: Used main
package.json
instead ofpackage.npm.json
- Version 11.3: Also used main
package.json
despite having the correctpackage.npm.json
- Both versions had to be unpublished due to Linux installation failures
- Main
package.json
hasauthenticate-pam
as a regular dependency package.npm.json
hasauthenticate-pam
as an optional dependency
authenticate-pam
is a regular dependency, npm fails the entire installation if PAM headers (libpam0g-dev) aren’t available.
Root Cause
The build script (scripts/build-npm.js
) checks for package.npm.json
and uses it if available, BUT:
- During
npm publish
, npm runs theprepublishOnly
script which triggersbuild:npm
- This rebuilds the package, potentially overwriting the correct configuration
- The timing and execution context can cause the wrong package.json to be used
The Solution
NEVER usenpm publish
directly! Instead:
-
Build the package explicitly:
-
Verify the package has the correct configuration:
-
Ensure
authenticate-pam
is underoptionalDependencies
: -
Publish the pre-built tarball:
Correct Release Process
1. Update Version Numbers
2. Build the Package
3. Verify the Build
4. Test Installation Locally
5. Publish
Package Configuration Files
package.json (Main Development)
- Used for development environment
- Has ALL dependencies including devDependencies
authenticate-pam
is a regular dependency (for development)- DO NOT USE FOR NPM PUBLISHING
package.npm.json (NPM Distribution)
- Used for npm package distribution
- Has only runtime dependencies
authenticate-pam
is an optional dependency- ALWAYS USE THIS FOR NPM PUBLISHING
Common Mistakes
-
Running
npm publish
without arguments- This triggers rebuild and may use wrong package.json
- Always publish pre-built tarball
-
Not verifying the package before publishing
- Always check that authenticate-pam is optional
- Test installation on Linux without PAM headers
-
Version mismatch
- Keep package.json, package.npm.json, and version.xcconfig in sync
Testing npm Package
Quick Docker Test
Verify Installation
Emergency Fixes
If you accidentally published with wrong configuration:-
Unpublish if within 72 hours (not recommended):
-
Publish a fix version:
- Increment version (e.g., 11.3 → 11.4)
- Follow correct process above
- Deprecate the broken version:
Release History & Lessons Learned
Version 11.1 (Good)
- Used
package.npm.json
correctly authenticate-pam
was an optional dependency- Linux installations worked without PAM headers
Version 11.2 (Bad - Unpublished)
- Accidentally used main
package.json
authenticate-pam
was a required dependency- Failed on Linux without libpam0g-dev
- Issue: Wrong package.json configuration
Version 11.3 (Bad - Unpublished)
- Also used main
package.json
despite fix attempts - Same Linux installation failures
- Issue: npm publish process overwrote correct configuration
Version 11.4 (Good)
- Built with explicit
pnpm run build:npm
- Published pre-built tarball
authenticate-pam
correctly optional- Linux installations work properly
Version 11.5 (Good)
- Published December 2024
- Built with explicit
pnpm run build:npm
- Published pre-built tarball:
vibetunnel-1.0.0-beta.11.5.tgz
- Verified
authenticate-pam
as optional dependency before publishing - Tagged as both
beta
andlatest
- Process followed correctly: All three version files updated, tarball verified, published with explicit filename
Version 12.1 (Good)
- Published July 2025
- Built with explicit
pnpm run build:npm
- Published pre-built tarball
authenticate-pam
correctly optional- Linux installations work properly
Version 12.2 (Good - Latest)
- Published July 17, 2025
- Built with explicit
pnpm run build:npm
- Published pre-built tarball:
vibetunnel-1.0.0-beta.12.2.tgz
- Verified
authenticate-pam
as optional dependency before publishing - Tagged with
beta
tag - Process followed correctly: All three version files updated (from beta.13 to beta.12.2), tarball verified, published with explicit filename
Summary
The critical lesson: package.npm.json must be used for npm distribution, not package.json. The build script supports this, but you must publish the pre-built tarball, not rely on npm’s prepublish hooks. Golden Rule: Always build first, verify the package configuration, then publish the tarball. Never usenpm publish
without arguments.