Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boxednode

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boxednode

Create a shippable binary from a JS file

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
18K
decreased by-20.91%
Maintainers
1
Weekly downloads
 
Created
Source

📦 boxednode – Ship a JS file with Node.js in a box

Take

  1. A JavaScript file
  2. Node.js

and pack them up as a single binary.

For example:

$ cat example.js
console.log('Hello, world!');
$ boxednode -s example.js -t example
$ ./example
Hello, world!

CLI usage

Options:
      --version       Show version number                              [boolean]
  -c, --clean         Clean up temporary directory after success       [boolean]
  -s, --source        Source .js file                        [string] [required]
  -t, --target        Target executable file                 [string] [required]
  -n, --node-version  Node.js version or semver version range
                                                         [string] [default: "*"]
      --tmpdir        Temporary directory for compiling Node.js source  [string]
      --help          Show help                                        [boolean]

Programmatic API

type CompilationOptions = {
  // Single Node.js version or semver range to pick from
  nodeVersionRange: string;

  // Optional temporary directory for storing and compiling Node.js source
  tmpdir?: string;

  // A single .js file that serves as the entry point for the generated binary
  sourceFile: string;

  // The file path to the target binary
  targetFile: string;

  // If true, remove the temporary directory created earlier when done
  clean?: boolean;
};

export function compileJSFileAsBinary(options: CompilationOptions);

Why this solution

We needed a simple and reliable way to create shippable binaries from a source file.

Unlike others, this solution:

  • Works for Node.js v12.x and above, without being tied to specific versions
  • Uses only officially supported, stable Node.js APIs
  • Creates binaries that are not bloated with extra features
  • Creates binaries that can be signed and notarized on macOS

Prerequisites

This package compiles Node.js from source. See the Node.js BUILDING.md file for a complete list of tools that may be necessary.

Not supported

  • Native addons
  • Multiple JS files

Similar projects

License

Apache-2.0

Keywords

FAQs

Package last updated on 21 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc