{"id":13527502,"url":"https://github.com/mongodb-js/boxednode","last_synced_at":"2025-08-03T02:13:22.730Z","repository":{"id":38472867,"uuid":"297444810","full_name":"mongodb-js/boxednode","owner":"mongodb-js","description":"📦 boxednode – Ship a JS file with Node.js in a box","archived":false,"fork":false,"pushed_at":"2024-12-12T15:40:40.000Z","size":226,"stargazers_count":643,"open_issues_count":6,"forks_count":14,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-06-28T04:17:01.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb-js.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-21T19:48:01.000Z","updated_at":"2025-06-25T20:03:34.000Z","dependencies_parsed_at":"2023-12-04T15:26:26.414Z","dependency_job_id":"b7e039f8-9f84-4ad8-94f2-e316c724ade9","html_url":"https://github.com/mongodb-js/boxednode","commit_stats":{"total_commits":79,"total_committers":7,"mean_commits":"11.285714285714286","dds":0.2784810126582279,"last_synced_commit":"16215d0ef2d904d4b43377bb8f8a97c6b8afeec2"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/mongodb-js/boxednode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-js%2Fboxednode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-js%2Fboxednode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-js%2Fboxednode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-js%2Fboxednode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb-js","download_url":"https://codeload.github.com/mongodb-js/boxednode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-js%2Fboxednode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268484362,"owners_count":24257660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T06:01:49.462Z","updated_at":"2025-08-03T02:13:22.688Z","avatar_url":"https://github.com/mongodb-js.png","language":"TypeScript","readme":"# 📦 boxednode – Ship a JS file with Node.js in a box\n\nTake\n\n1. A JavaScript file\n2. Node.js\n\nand pack them up as a single binary.\n\nFor example:\n\n```sh\n$ cat example.js\nconsole.log('Hello, world!');\n$ boxednode -s example.js -t example\n$ ./example\nHello, world!\n```\n\n## CLI usage\n\n```sh\nOptions:\n      --version         Show version number                            [boolean]\n  -c, --clean           Clean up temporary directory after success     [boolean]\n  -s, --source          Source .js file                      [string] [required]\n  -t, --target          Target executable file               [string] [required]\n  -n, --node-version    Node.js version or semver version range\n                                                         [string] [default: \"*\"]\n  -C, --configure-args  Extra ./configure or vcbuild arguments, comma-separated\n                                                                        [string]\n  -M, --make-args       Extra make or vcbuild arguments, comma-separated[string]\n      --tmpdir          Temporary directory for compiling Node.js source[string]\n      --help            Show help                                      [boolean]\n```\n\nNode.js versions may be specific versions, semver ranges, or any of the aliases\nsupported by https://github.com/pkgjs/nv/.\n\n## Programmatic API\n\n```js\ntype CompilationOptions = {\n  // Single Node.js version, semver range or shorthand alias to pick from\n  nodeVersionRange: string;\n\n  // Optional temporary directory for storing and compiling Node.js source\n  tmpdir?: string;\n\n  // A single .js file that serves as the entry point for the generated binary\n  sourceFile: string;\n\n  // The file path to the target binary\n  targetFile: string;\n\n  // Optional list of extra arguments to be passed to `./configure` or `vcbuild`\n  configureArgs?: string[];\n\n    // Optional list of extra arguments to be passed to `make` or `vcbuild`\n  makeArgs?: string[];\n\n  // If true, remove the temporary directory created earlier when done\n  clean?: boolean;\n\n  // Environment variables for build processes. Defaults to inheriting\n  // environment variables.\n  env?: { [name: string]: string | undefined };\n\n  // Specify the entrypoint target name. If this is 'foo', then the resulting\n  // binary will be able to load the source file as 'require(\"foo/foo\")'.\n  // This defaults to the basename of sourceFile, e.g. 'bar' for '/path/bar.js'.\n  namespace?: string;\n\n  // A list of native addons to link in.\n  addons?: AddonConfig[];\n\n  // Make sure the binary works for addons that use the `bindings` npm package,\n  // which would otherwise not be compatible with a single-binary model.\n  // By default, this is enabled if any addons are specified and\n  // disabled otherwise.\n  // (This will make `fs.accessSync('/node_modules')` not throw an exception.)\n  enableBindingsPatch?: boolean;\n\n  // A custom hook that is run just before starting the compile step.\n  preCompileHook?: (nodeSourceTree: string, options: CompilationOptions) =\u003e void | Promise\u003cvoid\u003e;\n\n  // A list of attributes to set on the generated executable. This is currently\n  // only being used on Windows.\n  executableMetadata?: ExecutableMetadata;\n};\n\ntype AddonConfig = {\n  // Path to the root directory of the target addon, i.e. the one containing\n  // a binding.gyp file.\n  path: string;\n\n  // A regular expression to match for `require()` calls from the main file.\n  // `require(str)` will return the linked binding if `str` matches.\n  // This will *not* be the same as `require(path)`, which usually is a JS\n  // wrapper around this.\n  requireRegexp: RegExp;\n};\n\ntype ExecutableMetadata = {\n  // Sets Windows .exe InternalName and ProductName\n  name?: string;\n\n  // Sets Windows .exe FileDescription\n  description?: string;\n\n  // Sets Windows .exe FileVersion and ProductVersion\n  version?: string;\n\n  // Sets Windows .exe CompanyName\n  manufacturer?: string;\n\n  // Sets Windows .exe LegalCopyright\n  copyright?: string;\n\n  // Provides the path to a .ico file to use for the\n  // Windows .exe file.\n  icon?: string;\n};\n\nexport function compileJSFileAsBinary(options: CompilationOptions);\n```\n\nThe `BOXEDNODE_CONFIGURE_ARGS` environment variable will be read as a\ncomma-separated list of strings and added to `configureArgs`, and likewise\n`BOXEDNODE_MAKE_ARGS` to `makeArgs`.\n\n## Why this solution\n\nWe needed a simple and reliable way to create shippable binaries from a source\nfile.\n\nUnlike others, this solution:\n\n- Works for Node.js v12.x and above, without being tied to specific versions\n- Uses only officially supported, stable Node.js APIs\n- Creates binaries that are not bloated with extra features\n- Creates binaries that can be signed and notarized on macOS\n- Supports linking native addons into the binary\n\n## Prerequisites\n\nThis package compiles Node.js from source. See the Node.js\n[BUILDING.md file](https://github.com/nodejs/node/blob/master/BUILDING.md) for\na complete list of tools that may be necessary.\n\n## Releasing\n\nTo release a new version, run the following command in main:\n\n```sh\nnpm version [patch|minor|major] \u0026\u0026 npm it \u0026 npm publish \u0026\u0026 git push origin main --tags\n```\n\n## Not supported\n\n- Multiple JS files\n\n## Similar projects\n\n- [pkg](https://www.npmjs.com/package/pkg)\n- [nexe](https://www.npmjs.com/package/nexe)\n\n## License\n\n[Apache-2.0](./LICENSE)\n","funding_links":[],"categories":["Packaging","TypeScript","Code packing"],"sub_categories":["Flexbox","Code2executable"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-js%2Fboxednode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb-js%2Fboxednode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-js%2Fboxednode/lists"}