yao-pkg / pkg

Package your Node.js project into an executable
https://www.npmjs.com/package/@yao-pkg/pkg
MIT License
395 stars 19 forks source link

Error: No native build was found for platform #66

Open chandirag opened 6 months ago

chandirag commented 6 months ago

What version of pkg are you using?

5.10.0

What version of Node.js are you using?

18.18.2

What operating system are you using?

Ubuntu 22.04.4 LTS

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node18-linuxstatic-armv7

Describe the Bug

My project uses the node-serialport library. I am getting the following error when trying to run the compiled binary:

pkg/prelude/bootstrap.js:1872
      throw error;
      ^

Error: No native build was found for platform=linux arch=arm runtime=node abi=108 uv=1 armv=default libc=glibc node=18.18.2
    loaded from: /snapshot/my-project/node_modules/@serialport/bindings-cpp

    at Function.<anonymous> (/snapshot/my-project/node_modules/node-gyp-build/node-gyp-build.js:60:9)
    at load (/snapshot/my-project/node_modules/node-gyp-build/node-gyp-build.js:22:30)
    at Object.<anonymous> (/snapshot/my-project/node_modules/@serialport/bindings-cpp/dist/load-bindings.js:11:46)
    at Module._compile (pkg/prelude/bootstrap.js:1930:22)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at Module.require (pkg/prelude/bootstrap.js:1851:31)
    at require (node:internal/modules/cjs/helpers:119:18)

Node.js v18.18.2

I also get the following warning during compilation (when running npm run package):

> pkg@5.10.0
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=18.18.2 runtime=node arch=armv7 libc= platform=undefined)
prebuild-install warn install No prebuilt binaries found (target=v18.18.2 runtime=node arch=armv7 libc= platform=undefined)

I have the following package.json:

{
    "name": "my-project",
    "version": "0.0.1",
    "description": "",
    "bin": "dist/src/main.js",
    "scripts": {
        "build": "nest build",
        "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
        "start": "nest start",
        "package": "npm run build && mkdir -p bin && npx pkg ."
    },
    "dependencies": {
        "@nestjs/common": "^10.0.0",
        "@nestjs/config": "^3.2.2",
        "@nestjs/core": "^10.0.0",
        "@nestjs/platform-express": "^10.0.0",
        ...
        "serialport": "^10.5.0",
    },
    "devDependencies": {
        "@nestjs/cli": "^10.0.0",
        "@nestjs/schematics": "^10.0.0",
        "@nestjs/testing": "^10.3.8",
        ...
    },
    "pkg": {
        "scripts": "dist/**/*.js",
        "targets": [
            "node18-linuxstatic-armv7"
        ],
        "assets": [
            "./node_modules/@serialport/bindings-cpp/**"
        ],
        "outputPath": "bin"
    }
}

What I've already tried:

I still keep getting the above error. Any help is appreciated.

Expected Behavior

Compiled binary to execute without throwing Error: No native build was found for platform=linux arch=arm runtime=node abi=108 uv=1 armv=default libc=glibc node=18.18.2

To Reproduce

Compiling any new node project which utilizes the serial port library