Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/niraj-khatiwada/nodejs-as-a-single-binary

Compiling Node.js project into a single binary file
https://github.com/niraj-khatiwada/nodejs-as-a-single-binary

Last synced: about 1 month ago
JSON representation

Compiling Node.js project into a single binary file

Awesome Lists containing this project

README

        

# Running Node.js project as a single executable binary

Steps:

1. Make a single javascript bundle file using `esbuild`.

```
pnpm bundle
```

2. Package the bundled file into a single executable binary using `@yao-pkg/pkg`

```
pkg bundle/bundle.js -o ./bin/server-
```

You need to make binaries for the platform you want to support. By default it generates one for the platform that your machine is using. See [target](https://github.com/yao-pkg/pkg?tab=readme-ov-file#targets) section for more info.

OR

If you have Rust installed, you can just run:

```
pnpm package
```

The above command will add appropriate binary name of your platform.