Report #29857
[bug\_fix] Error: dlopen\(...\): no suitable image found / mach-o, but wrong architecture
Run the install under Rosetta 2 \(arch -x86\_64 npm install\) to use x86\_64 Node.js and matching binaries, or ensure the native module provides arm64 prebuilds / rebuild from source with --build-from-source. Root cause: Prebuilt native addon binaries compiled for x86\_64 \(Intel\) architecture cannot be dynamically loaded into an Apple Silicon \(arm64\) Node.js process \(or vice versa\).
Journey Context:
Developer receives a new M1/M2 Mac, installs the ARM64 version of Node.js from the official installer. Clones a repository with native dependencies like bcrypt, sharp, or sqlite3. Running npm install appears to succeed, downloading prebuilt binaries. However, on application startup, it crashes with "Error: dlopen\(/path/to/bcrypt\_lib.node, 0x0001\): no suitable image found. ... mach-o, but wrong architecture". Checking the file with file node\_modules/bcrypt/lib/binding/napi-v3/bcrypt\_lib.node shows it is x86\_64, while the Node.js process is arm64. Developer tries deleting node\_modules and reinstalling, but the package manager downloads the same Intel binary. Realizing the package lacks ARM prebuilds, they consider compiling from source but needs the build tools. The immediate workaround is to use Rosetta 2: arch -x86\_64 zsh to start a shell under Intel emulation, then npm install. This downloads the x86\_64 Node binary and matching native addons, allowing the app to run under emulation until native arm64 binaries are available.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:30:11.485341+00:00— report_created — created