{"id":13733500,"url":"https://github.com/coder/nbin","last_synced_at":"2025-12-12T00:38:58.105Z","repository":{"id":52000622,"uuid":"176977655","full_name":"coder/nbin","owner":"coder","description":"Fast and robust node.js binary compiler.","archived":true,"fork":false,"pushed_at":"2021-05-10T03:44:26.000Z","size":792,"stargazers_count":108,"open_issues_count":16,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-06T04:46:33.960Z","etag":null,"topics":["binaries","compiler","nodejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-21T15:50:36.000Z","updated_at":"2025-03-03T05:36:54.000Z","dependencies_parsed_at":"2022-08-28T09:02:19.205Z","dependency_job_id":null,"html_url":"https://github.com/coder/nbin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fnbin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fnbin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fnbin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fnbin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/nbin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804206,"owners_count":21806769,"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","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":["binaries","compiler","nodejs"],"created_at":"2024-08-03T03:00:44.284Z","updated_at":"2025-10-21T19:35:11.557Z","avatar_url":"https://github.com/coder.png","language":"TypeScript","readme":"# nbin \u0026middot; [![\"Open Issues\"](https://img.shields.io/github/issues-raw/cdr/nbin.svg)](https://github.com/cdr/nbin/issues) [![\"Version\"](https://img.shields.io/npm/v/@coder/nbin.svg)](https://www.npmjs.com/package/@coder/nbin) [![MIT license](https://img.shields.io/badge/license-MIT-green.svg)](#) [![Discord](https://discordapp.com/api/guilds/463752820026376202/widget.png)](https://discord.gg/zxSwN8Z)\n\nFast and robust node.js binary compiler.\n\n**WARNING:** This project was created for\n[code-server](https://github.com/cdr/code-server) and may provide limited\nsupport.\n\nWhy was this made? Why not use `pkg` or `nexe`?\n\n- Support for native node modules.\n- No magic. The user specifies all customization. An example of this is\n  overriding the file system.\n- First-class support for multiple platforms.\n\n## Usage\n\n`nbin` does not do any kind of scanning for requiring files; it only includes\nthe files you tell it to. That means you should include everything (for example\nby using `writeFiles('/path/to/repo/*')`) or use a bundler like Webpack and\ninclude the bundle.\n\nWhen running within the binary, your application will have access to a module\nnamed [`nbin`](typings/nbin.d.ts).\n\nTwo packages are provided:\n- `@coder/nbin` - available as an API to build binaries.\n- `nbin` - *ONLY* available within your binary.\n\n### Example\n\n```ts\nimport { Binary } from \"@coder/nbin\";\n\nconst bin = new Binary({\n  mainFile: \"out/cli.js\",\n});\n\nbin.writeFile(\"out/cli.js\", Buffer.from(\"console.log('hi');\"));\nconst output = bin.bundle();\n```\n\n### Forks\n\nTo use the compiled binary as the original Node binary set the `NBIN_BYPASS`\nenvironment variable. This can be especially useful when forking processes (or\nspawning with the binary). You might want to simply immediately set this to any\ntruthy value as soon as your code loads.\n\n### Webpack\n\nIf you are using webpack to bundle your `main`, you'll need to externalize\nmodules.\n\n```ts\n// webpack.config.js\n\nmodule.exports = {\n  ...\n  external: {\n    nbin: \"commonjs nbin\",\n    // Additional modules to exclude\n  },\n};\n```\n\n### Environment\n\nYou can pass\n[`NODE_OPTIONS`](https://nodejs.org/api/cli.html#cli_node_options_options).\n\n```bash\nNODE_OPTIONS=\"--inspect-brk\" ./path/to/bin\n```\n\nGzip'd JavaScript files are supported to reduce bundle size.\n\n## Development\n\n```\nyarn\nyarn build\n```\n\nWhen publishing use `npm` and not `yarn` as `yarn` will traverse ignored\ndirectories anyway and re-add anything excluded by any discovered `.gitignore`\nfiles.\n\n### Patching\n\nWe patch Node to make it capable of reading files within the binary.\n\nTo generate a new patch, **stage all the changes** you want to be included in\nthe patch in the Node source, then run `yarn patch:generate` in this\ndirectory.\n","funding_links":[],"categories":["Packaging"],"sub_categories":["Flexbox"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fnbin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fnbin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fnbin/lists"}