GitNexus Universal Bundler CLI
raw JSON →The `gitnexus-bundler` is a Command Line Interface (CLI) tool, currently at version `1.0.2`, specifically engineered to compile Node.js and Next.js applications into a single, self-contained CommonJS (`.cjs`) executable for deployment within GitNexus WebContainer environments. It streamlines the deployment process by bundling the entire backend server logic—leveraging `esbuild` for efficient compilation—and can optionally integrate and embed frontend static assets into the final `.cjs` artifact. This tool runs locally on the developer's machine, generating both the executable bundle and a `gitnexus.json` manifest for hosting. Its key differentiators include its targeted optimization for GitNexus deployments, support for full-stack applications with integrated frontend build steps and static asset embedding, and the production of a highly portable, single-file application executable, distinguishing it from multi-file serverless or container deployments. The package maintains an active development status, with updates focusing on features and stability.
Common errors
error Error: The module 'bcrypt' was compiled against a different Node.js version. This version of Node.js cannot load this module. ↓
bcryptjs for bcrypt) or refactor to use a cloud service that handles the native functionality externally. error Error: listen EADDRNOTAVAIL: address not available 127.0.0.1:8080 ↓
listen call to app.listen(8080, '0.0.0.0', () => ...) to ensure it binds to the correct address and port for GitNexus. error Refused to frame 'https://your-bundle-url.pages.dev/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'". ↓
frame-ancestors, and potentially crossOrigin*Policy settings, as outlined in the Architectural Guidelines for GitNexus. Warnings
breaking Applications bundled for GitNexus WebContainers must not use Node.js native C++ addons (e.g., `bcrypt`, `node-sass`, `canvas`, `sharp`, `sqlite3`, `puppeteer`). These modules are incompatible with the WebContainer environment due to their dependency on compiled C++ binaries. ↓
gotcha Your Node.js application server must explicitly listen on port `8080` and host `0.0.0.0` to be accessible within the GitNexus WebContainer environment. ↓
gotcha When using security middleware like Helmet, default Content Security Policy (CSP), Frameguard, and Cross-Origin policies can block your application within the GitNexus WebContainer, which operates in an iframe-based environment. ↓
gotcha While GitHub Releases can host your `.cjs` bundle for testing, it has significant limitations including 1 GB/month bandwidth on free accounts and requires manual uploads. It's not suitable for production or automated deployments. ↓
Install
npm install gitnexus-bundler yarn add gitnexus-bundler pnpm add gitnexus-bundler Imports
- gitnexus-bundler wrong
gitnexus-bundler build -i src/server.jscorrectnpx gitnexus-bundler build -i src/server.js - build wrong
npx gitnexus-bundler -i server.jscorrectnpx gitnexus-bundler build -i server.js -f "npm run build" -s out - Global Installation wrong
npx gitnexus-bundler build -i src/index.tscorrectnpm install -g gitnexus-bundler gitnexus-bundler build -i src/index.ts
Quickstart
npm init -y
npm install express
// src/server.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello from GitNexus Bundler!');
});
app.listen(8080, '0.0.0.0', () => {
console.log('Server listening on http://0.0.0.0:8080');
});
// Bundle the backend application
npx gitnexus-bundler build -i src/server.js -o gitnexus-bundle.cjs
console.log('\nBundle created: gitnexus-bundle.cjs');
console.log('Next, host gitnexus-bundle.cjs (e.g., on Cloudflare Pages) and update gitnexus.json');