Git Product home page Git Product logo

pkg-binaries's Introduction

Pkg Binaries

PRs Welcome

Buy Me A Coffee PayPal Patreon

Collection of NodeJS precompiled binaries to use with pkg. Please submit a pull request if you have others that are not present here.

ALL BINARIES HAVE BEEN MOVED TO RELEASES ASSETS. YOU WILL FIND ALL BINARIES HERE

Usage

Download the binary inside pkg cache folder before compiling your application.

Example with armv7 node v16.16.0 linux:

CACHE=~/.pkg-cache/custom #custom cache folder
mkdir -p $CACHE
export PKG_CACHE_PATH=$CACHE
export PKG_IGNORE_TAG=true # prevents pkg-fetch to add a tag folder
curl https://github.com/yao-pkg/pkg-binaries/releases/download/node16/built-v16.16.0-linux-armv7 -LO $CACHE/built-v16.16.0-linux-armv7 # download the binary, be sure it is prefixewd with built-, otherwise it will not work
npx pkg -t node16-linux-armv7 . # compile your application

ATTENTION

Once you have placed the file in .pkg-cache folder check that the output of file command gives you the correct interpreter:

pi@NanoPi-NEO-Plus2:~/.pkg-cache/v2.6$ file fetched-v8.11.3-linux-arm64
fetched-v8.11.3-linux-arm64: ELF 64-bit LSB shared object, ARM aarch64, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.7.0, BuildID[sha1]=02bf3444ecc520c4da40e89cbfbf6831e3a205ea, not stripped

Sometimes when using wget it could be downloaded as HTML text file and it wouldn't work.

Utils

In utils folder you will find a bash script package.sh that I have created to package my nodejs application.

Copy the script in your app directory and edit it with your appName and the destination folder of the pkg compiled output.

# EDIT THIS WITH YOUR VALUES
APP="appName"
PKG_FOLDER="pkg"

It also automatically scan node_modules folder and adds required .node files that pkg is not able to package.

You will find all your files inside the destination folder and they will be also packaged inside a .zip file with appName and version choosed.

If you want to make things more easy add a script in your package.json file:

"scripts": {
  "start": "sudo node ./bin/www", //default to start the application
  "package": "sudo chmod +x package.sh && ./package.sh"
}

Than simply run npm run package to start the script

Compilation guide

Using Docker

This allows to compile nodejs pkg binary for arm32 (armv7l, armv6) and arm64 archs from a x86_64.

Steps

# Clone this repo
git clone https://github.com/robertsLando/pkg-binaries.git
cd pkg-binaries
# Build the required binary
chmod +x build.sh
./build.sh
# Follow build steps and wait for nodejs to be compiled (WILL TAKE AROUND 24 HOURS!)

Manually

This requires to run commands in a CPU with the required build ARCH

Here is a guide to manually compile a nodejs binary from source. Usually pkg automatically compiles this binary if it doesn't find them in his resources but this process may fail and this is how to do it by your self. In this example I'm compiling nodejs 8 LTS using a device with Linux with architecture arm64 (to check the information about your device run the comand uname -a).

  1. Install required build tools:

    sudo apt-get install build-essential

  2. Than clone node:

    git clone https://github.com/nodejs/node.git

  3. Checkout to the desired version:

    cd node git checkout v8.11.3

  4. Create the patch file inside the node dir and paste the content from the patch file you find on pkg-fetch github inside patch directory (https://raw.githubusercontent.com/zeit/pkg-fetch/master/patches/node.v8.11.3.cpp.patch)

    sudo nano node.v8.11.3.cpp.patch (Ctrl+Maiusc+V - Ctrl+X - Y)

    git apply node.v8.11.3.cpp.patch

    ./configure

    make (this takes many minutes, even hours in some devices)

  5. Finally copy the binary:

    cp node ~/.pkg-cache/v2.6/fetched-v8.11.3-linux-arm64

pkg-binaries's People

Contributors

munelear avatar n1ru4l avatar robertslando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pkg-binaries's Issues

Not working as expected for ARMv7

I downloaded the binaries using curl into ~/.pkg-cache/custom.
Then set the environment variables as mentioned in the README.

I am using the latest version of @yako-pkg/pkg. (v5.11.5).

Within my project folder I have a single index.js file. When I run the command:
npx pkg -t node16-linux-armv7 index.js

I get the following output:

> [email protected]
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v16.20.2-linux-armv7        [                    ] 0%
> Error! 404: Not Found
> Not found in remote cache:
  {"tag":"v3.5","name":"node-v16.20.2-linux-armv7"}
> Building base binary from source:
  built-v16.20.2-linux-armv7
> Fetching Node.js source archive from nodejs.org...
  node-v16.20.2.tar.gz.sha256sum      [====================] 100%
  node-v16.20.2.tar.gz                [=                   ] 7%^

It doesn't recognize the built-v16.16.0-linux-armv7 binary within ~/.pkg-cache/custom and tries to build from source.

I have both @yao-pkg/pkg and my project folders within WSL2 in my Windows machine with a x86 architecture. I need to cross compile into armv7 within this environment. Any help would be appreciated.

Fetched and Node version numbers.

Can you please explain the co-relation between the version number in fetched-vx.y.z and Node versions? The documentation has an example for arm64, node v8.11.3 on linux where, the binary being downloaded is fetched-v14.0.0-linux-armv6. It is then renamed to fetched-v8.11.3-linux-arm64.

How do we know that v14.0.0 of the pre-built binary maps to v8.11.3 NodeJS version? Specifically, in my case, my NodeJS version is 10.21.0 and I need the pre-built binary for armv6. Can I therefore, download v14.4.0 and rename it to v10.21.0 NodeJS version?

check whether self-hosted action runner is still necessary when utilising multiple cores

Does this work with latest pkg?

Using pkg 5.3.1 which uses pkg-fetch 3.2.2, downloaded binary for arm6, moved it into the cache folder but pkg still tries to build from source.

root@1611399:/usr/src# ls -al ~/.pkg-cache/v3.2/
total 92800
drwxr-xr-x 2 root root     4096 Aug 24 14:56 .
drwxr-xr-x 3 root root     4096 Aug 24 14:51 ..
-rwxr-xr-x 1 root root 28755972 Aug 24 14:56 fetched-v12.22.2-linuxstatic-armv7
-rwxr-xr-x 1 root root 66259348 Aug 24 14:52 fetched-v14.0.0-linux-armv6

v12.16.1-linux-armv6 segmentation fault

I get a segmentation fault trying the pre-built v12.16.1 on a raspberry pi zero.

Version v12.13.1-linux-armv6 gives an invalid instruction error.
Version v8.16.0-linux-armv6 works.

android x86

Hello, could you build the binary file for android x86?

Nodejs 16/18 binaries are empty in releases

I like your repo because I saw the arm7 for the Linux node16, but when I look at the releases the said binary does not exist and your build workflow is also failing, maybe that's why. Is there a chance we can fix that and able to produce the right binary?

macos-x64, win-x64, alpine-x64 and linux-x64 binaries

Would also be nice to have those over here as pkg-fetch repository is only infrequently maintained.

macos and win binaries must be built without docker buildx as there is no way to emulate that. Fortunately, GitHub actions does have support for both macos and win. Because of that the build should also not take that long and require a custom builder.

cross compilation error

I'm trying to cross compile from x64 to arm64 a simple hello world:
~/test$ cat hello.js
console.log('hello');

but I have the following error:
~/test$ pkg -t node8-linux-arm64 hello.js

[email protected]
Warning Failed to make bytecode node8-arm64 for file /snapshot/test/hello.js

the resulting binary not start on arm64 board.

Armv6 binary for node10

Hi!
I am using
node version == v10.16.0
pkg version == 4.4.0
Raspberry pi zero w == Linux_armv6
It just hangs at the make

Error in Pi zero

After many hours make still did not progress.
Is there any way I can use the NodeJS that is already installed or can you please upload the binaries for Linux-armv6 with node10?

[action] Automated builds

This issue is used to trigger actions to build pkg binaries using github actions.

Usage: <arch> <nodeVersion> <os>

  • arch: arm32v6 | arm32v7 | arm64
  • node: node
  • os: linux | alpine

Unknown flags with build.sh

# ๎‚ฐ ./build.sh          
1) arm32v6
2) arm32v7
3) arm64
Architecture: >2

1) Node 8 LTS (Carbon)
2) Node 10 LTS (Dubnium) 
3) Node 12 LTS (Current)
NodeJS version: >3

1) linux
2) alpine
OS version: >1

unknown flag: --progress

# after removing --progress parameter in build.sh:159, this was the output
unknown shorthand flag: 'f' in -f

# after removing even -f in build.sh:159, this was the output
unknown flag: --platform

basically my docker is completely unsure about this command:

docker buildx build --progress plain -f Dockerfile.build \
	--platform $platform \
	--build-arg PKG_NODE="$pkg_node" \
	--build-arg PKG_OS="$pkg_os" \
	--build-arg PKG_ARCH="$pkg_arch" \
	--build-arg NPROC="$NPROC" \
	--load \
	-t ${arch}/pkgbinaries:${pkg_os}-${pkg_node} .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.