Re: Is it possible to build node package as single executable binary?

From: Hiroki Tagato <tagattie_at_FreeBSD.org>
Date: Fri, 23 Jun 2023 11:11:41 UTC
Hi Miroslav,

I have a WIP port of Bitwarden CLI in my forked ports repository.

Take a look at:
https://github.com/tagattie/freebsd-ports/tree/main/security/bitwarden-cli

It generates a single binary executable "bw" by packaging the node 
command and necessary node modules. I have only lightly tested the 
package on FreeBSD 13/amd64 and it seems working.

Hope this helps.

Cheers,
Hiroki

On 2023/06/23 5:44, Miroslav Lachman wrote:
> Node.js / npm packages can be built in to single executable binary 
> containing all node modules and node.js executable = everything packaged 
> in one large executable, but by default it works for Win, Mac and Linux, 
> not for FreeBSD.
> 
> Is there somebody successfully using it on FreeBSD?
> 
> I would like to build Bitwarden's CLI command "bw" 
> https://bitwarden.com/help/cli/
> It can be installed on FreeBSD by "npm install @bitwarden/cli" and it 
> works but can easily break with Node.js upgrade, that's why I would 
> prefer to build it as single executable as it is distributed for Win, 
> Max and Linux (it is called "Native executable" on Bitwearden's web)
> 
> Source code is on Github
> https://github.com/bitwarden/clients/tree/master/apps/cli
> 
> But I don't know how to build only apps/cli (npm install in this 
> subdirectory failed with missing modules and npm install in top level 
> failed on electron install, because it tries to build everything, not 
> only CLI bw)
> 
> Info for npm pkg https://github.com/vercel/pkg
> 
> I am not node / JS developer, my knowledge of building node packages 
> with npm / npx is very limited.
> Any help is really appreciated.
> 
> 
> Kind regards
> Miroslav Lachman