Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Weird, not working just out of the box in the simplest scenario (details inside) #705

Closed
almosnow opened this issue Jun 3, 2019 · 9 comments
Labels

Comments

@almosnow
Copy link

almosnow commented Jun 3, 2019

I literally just did npm install -g pkg followed by pkg main.js --out-path build/

(main.js being, of course, the name of my node script)

After running this (with no errors) I get three files (main-linux, main-macos, main-win.exe) on my build/ directory.

When I try to run build/main-macos it fails with the following message:

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

Error: No native build was found for platform=darwin arch=x64 runtime=node abi=57 uv=1 libc=glibc
...

Any idea on why this is happening?


Node version: v8.12.0
NPM version: 6.4.1
OS: MacOS 10.13.6

@almosnow
Copy link
Author

Is anyone paying attention to this? This is a serious issue, it really undermines the reliability of the project 😬

@lefuturiste
Copy link

Can you share the exact setup of your environment and the code (like a git repository)

@johnsonjo4531
Copy link

@lefuturiste @almosnow I was running into this issue too. I created a GitHub gist recreating the issue here (which has steps for reproduction and also shows the script runs normally without pkg): https://gist.github.com/johnsonjo4531/cbdace0097f9a658fd7c3ff439f5111e. My problem seems to be using the secure-password package. Here's the rest of the stack trace which seems to indicate that node-gyp-build couldn't find the build for sodium-native on the current platform:

> test@1.0.0 docker:run ~/Documents/code/docker/bins/test
> docker container run -t failed-pkg

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

Error: No native build was found for platform=linux arch=x64 runtime=node abi=64 uv=1 libc=musl
    at Function.load.path (/snapshot/app/node_modules/node-gyp-build/index.js:56:9)
    at load (/snapshot/app/node_modules/node-gyp-build/index.js:20:30)
    at Object.<anonymous> (/snapshot/app/node_modules/sodium-native/index.js:1:101)
    at Module._compile (pkg/prelude/bootstrap.js:1261:22)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:710:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:635:17)
    at Module.require (pkg/prelude/bootstrap.js:1166:31)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 docker:run: `docker container run -t failed-pkg`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the test@1.0.0 docker:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!    ~/.npm/_logs/2019-09-12T00_50_15_707Z-debug.log

@johnsonjo4531
Copy link

Also, this issue seems to be linked to #758. If you look at the module there leveldown it seems to be using node-gyp-build the same way that the package sodium-native uses node-gyp-build.

@christianbundy
Copy link

FWIW, I'm also having this problem with leveldown and libsodium. I'll share any info if I can fix it. 🤞

@VoltanaDMG
Copy link

I'm not sure if this issue is still tracked by the creator but I have a question:

Which NodeJS version are using?

Because the CI of this module checks only up to v10. It could be a problem with a newer NodeJS version.

@Xemorph
Copy link

Xemorph commented Nov 29, 2019

Hey, I tested your problem with Travis CI and a Debian OS, this isn't an error by pkg itself.
The error message comes from node-gyp-build and those developers pointed out that node-gyp-build@4 supports pkg.

The developer of secure-password should check out if sodium-native has a newer version and this should use at least node-gyp-build@4.

ASAP I will try to update secure-password and check if the packaging works (again).


Update: 30th Nov. 2019
At this repository failed-pkg I updated secure-password, which uses the newest version of sodium-native. I will provide later some binaries for MacOS, Linux & Windows with the packaged NodeJS v10 and precheck if everything works fine now.

ASAP I'll update this comment with new information.


Update: 30th Nov. 2019 2pm
I finally resolved the problem but I need to correct myself.
No one is guilty of the above error because the developers of pkg are saying following to native addons

Native addons (.node files) use is supported, but packaging .node files inside the executable is not resolved yet. You have to deploy native addons used by your project to the same directory as the executable.
When a package, that contains a native module, is being installed, the native module is compiled against current system-wide Node.js version. Then, when you compile your project with pkg, pay attention to --target option. You should specify the same Node.js version as your system-wide Node.js to make compiled executable compatible with .node files.

Link: https://github.com/zeit/pkg/#native-addons

The second part of the quote is the key to this problem. I'll try to explain it with an example:

Configuration:
OS: Windows 10
NodeJS v10.15.3
Yarn v1.19.2
secure-password -> https://github.com/Xemorph/failed-pkg/tree/master/secure-password

So, our application is looking for this module node.node.abi64.uv1.glibc.node but there is one problem, sodium-native doesn't ship this prebuild. And that isn't all, pkg builds the executable with our installed NodeJS version which means that the module above needs to be build with the same NodeJS version.
But how to fix this problem? Just compile the module yourself and afterwards you copied the files to the right places, your folder structure should look like this:

root/
|- index-win.exe
|- prebuilds
   |- win32-x64
      |- node.node.abi64.uv1.glibc.node
      |- libsodium.dll

This is an example for Windows!

Yeah and then it should work, btw I uploaded my build version for Windows 10 with NodeJS v10.15.3.
Don't hesitate to contact me if you have any questions

>> I think this issue can be closed now!


Attachments
failed_pkg.zip

@github-actions
Copy link

github-actions bot commented Apr 1, 2021

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label

@github-actions github-actions bot added the Stale label Apr 1, 2021
@github-actions
Copy link

github-actions bot commented Apr 6, 2021

This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.

@github-actions github-actions bot closed this as completed Apr 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants