yao-pkg / pkg

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

Error: No native build was found for platform=linux #61

Closed LMJayasundara closed 3 months ago

LMJayasundara commented 3 months ago

What version of pkg are you using?

5.10.0

What version of Node.js are you using?

v16.20.2

What operating system are you using?

Linux

What CPU architecture are you using?

x86_64

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

node16-linuxstatic-armv7

Describe the Bug

I am trying to build the code with serialport lib i get an errror. i am using linux machine for build the code to armv7l target machine. when i build code without serialport its work perfect. how i solve it

Build machine 1

Target machine 2

Package.json

{
  "name": "gbt_charger",
  "version": "1.0.0",
  "description": "",
  "main": "base.js",
  "bin": "base.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "pkg": {
    "assets": [
      "/usr/lib/node_modules/serialport/node_modules/@serialport/bindings-cpp/**/*"
    ]
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ajv": "^8.12.0",
    "ajv-formats": "^2.1.1",
    "easy-crc": "^1.1.0",
    "hex2dec": "^1.1.2",
    "uuid": "^9.0.1",
    "winston": "^3.11.0",
    "winston-daily-rotate-file": "^5.0.0",
    "ws": "^8.14.2",
    "xstate": "^4.38.2"
  }
}

in code i import lib as:

// some module import from current dir nodemodules 
const { createMachine, interpret, assign, actions } = require('xstate');

// some module import from another file path installed nodemodules folder (like global)
const { open } = require('/usr/lib/node_modules/lmdb');
const { SerialPort } = require('/usr/lib/node_modules/serialport');
const { ByteLengthParser } = require('/usr/lib/node_modules/@serialport/parser-byte-length');

but i got error every time shown in Traget machine png

Expected Behavior

_

To Reproduce

_

robertsLando commented 3 months ago

Add this to package.json:

"pkg": {
        "scripts": [],
        "assets": [
            "./node_modules/node-gyp-build/**",
            "./node_modules/@serialport/bindings-cpp/**"
        ]
    },
LMJayasundara commented 3 months ago

got same error with compile warning 3

robertsLando commented 3 months ago

you have to pass in package.json I don't think it got it, is package.json inside /home/ubuntu/gbt/code?

LMJayasundara commented 3 months ago

What do you mean pass

robertsLando commented 3 months ago

is package.json inside /home/ubuntu/gbt/code?

LMJayasundara commented 3 months ago

Yes, it is. 🥺

robertsLando commented 3 months ago

Ok but after compile you dind't tried to run it? Sometimes warnign can be ignored

LMJayasundara commented 3 months ago

I run it and get same error message i send you

robertsLando commented 3 months ago

I have a feel the problem here is that you are not running the command from inside the package.json folder, could you try to do so? also remember to change the last path with .

LMJayasundara commented 3 months ago

Yes i run command from outside. Ok, I will try and let you know