Report #17233
[bug\_fix] dlopen: mach-o, but wrong architecture / was compiled for a different architecture
Delete node\_modules and rebuild for the correct architecture. Ensure you are using a Node.js binary matching your terminal architecture \(ARM64 for native Apple Silicon, x64 for Rosetta\). Force rebuild with ARCHFLAGS="-arch arm64" npm install for ARM64, or arch -x86\_64 npm install for x64 under Rosetta. Root cause: Native Node.js addons \(.node files\) are compiled for a specific CPU architecture \(arm64 vs x86\_64\) and cannot be loaded by a Node.js process running under a different architecture.
Journey Context:
Developer on an M2 MacBook Pro clones a repository originally set up by teammates using Intel Macs. They run npm install successfully, but when executing node index.js, the process crashes with 'dlopen: mach-o, but wrong architecture' pointing to bcrypt.node. The developer tries npm rebuild, which fails with the same error. They notice that Activity Monitor shows their Terminal is running under 'Rosetta' \(Intel emulation\). They delete node\_modules, switch to a native ARM64 build of Node.js \(downloaded from nodejs.org as darwin-arm64\), ensure Terminal is not using Rosetta, and reinstall. The native addon now compiles for arm64 and loads successfully. Alternatively, when they need to support an x86\_64 Node.js binary for compatibility, they must run the install under Rosetta to get x86\_64 binaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:49:43.377335+00:00— report_created — created