question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

node-pre-gyp doesn't handle arm architectures properly.

See original GitHub issue

The “arm” target in itself isn’t enough. If you look at node binary distributions, you have 3 variants for arm: armv6l, armv7l, and arm64.

An example of an armv6l platform is a raspberry pi zero. Installing nodejs on a raspberry pi zero through nvm will yield the correct download of the correct binary (armv6l).

An example of an armv7l platform is a raspberry pi 3. Installing nodejs on a raspberry pi 3 through nvm will also yield the correct download of the correct binary (armv7l).

However, for both platforms, node-pre-gyp identify them as “arm”, meaning we can only cross compile and publish a single version of node-pre-gyp packages, either armv6l or armv7l, which aren’t interchangeable due to dynamic library versions and tags.

This creates a problem where users will be able to download the wrong version of the package for their platform, and crash on load. The only method for them to fix it is to uninstall the node-pre-gyp enabled package, and re-install it using a flag to force falling back on ignoring published packages and compile from source instead, which is not obvious.

Also, the documentation states that the only correct values for --target_arch are ia32, x64 and arm, whereas arm64 is in fact a valid keyword to use here. The produced packages work properly on an arm64 environment.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:13
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
daniellockyercommented, Apr 17, 2022

Unfortunately I just ran into this when reworking node-sqlite3’s prebuilt binaries 😕 It’d be great to fix armv6 and armv7 in node-pre-gyp but I’ll have to keep them disabled for now

1reaction
springmeyercommented, Feb 9, 2021

@inukshuk thanks. If process.arch is arm64 on silicon macbooks then I don’t see a problem here with node-pre-gyp because the existing versioning information is suitable for macbooks. So the problem is that the module that integrates node-pre-gyp needs to properly create arm64 binaries, detect them, and require them at runtime. The error you are seeing:

/node_modules/sqlite3/lib/binding/napi-v6-darwin-arm64/node_sqlite3.node: mach-o, but wrong architecture

Indicates that the sqlite3 module is incorrectly packaging its binary. So this is a problem with node-sqlite3 then not node-pre-gyp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving common issues with node-gyp - LogRocket Blog
Many node-gyp issues are actually issues with the toolchain used for building add-on code. We'll categorize these issues to offer solutions.
Read more >
node.js - Error with npm install - a pre-gyp error - Stack Overflow
I had to install python first python.org, you need to use version 2.7 as node-gyp doesn't support the later versions. So install python...
Read more >
node-pre-gyp | Yarn - Package Manager
A command line tool called node-pre-gyp that can install your package's C++ module from a binary. A variety of developer targeted commands for...
Read more >
Native Node Modules | Electron
Native Node.js modules are supported by Electron, but since Electron has a different application ... Tell node-pre-gyp to build module from source code....
Read more >
subject:"Re\: \[OE\-core\] \[RFC\]\[PATCH 0\/6\] NPM refactoring"
I've commented out "DEPENDS_append_class-native" handling now, as this should work without tricks these days. node-pre-gyp support wasn't fully implemented ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found