strongloop / modern-syslog

modern-syslog
Other
49 stars 19 forks source link

npm install builds incorrectly on MacBook M3 - error: "mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')" #44

Open kjrhody opened 6 months ago

kjrhody commented 6 months ago

When I run npm install the build finishes but it seems to build with the x86_64 architecture instead of the new arm64 architecture needed for the M3 chip that my computer uses. Then when I try to run my application, I get the following error:

W20240322-10:25:49.037(-4)? (STDERR) /Users/x/.meteor/packages/promise/.0.12.2.1p12lm2.cswei++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/promise_server.js:218
W20240322-10:25:49.037(-4)? (STDERR)       throw error;
W20240322-10:25:49.037(-4)? (STDERR)       ^
W20240322-10:25:49.037(-4)? (STDERR) 
W20240322-10:25:49.037(-4)? (STDERR) Error: dlopen(/Users/x/node_modules/modern-syslog/build/Release/core.node, 0x0001): tried: '/Users/x/node_modules/modern-syslog/build/Release/core.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/x/node_modules/modern-syslog/build/Release/core.node' (no such file), '/Users/x/node_modules/modern-syslog/build/Release/core.node' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
W20240322-10:25:49.037(-4)? (STDERR)     at Object.Module._extensions..node (internal/modules/cjs/loader.js:1175:18)
W20240322-10:25:49.037(-4)? (STDERR)     at Module.load (internal/modules/cjs/loader.js:981:32)
W20240322-10:25:49.037(-4)? (STDERR)     at Module.Mp.load (/Users/x/.meteor/local/build/programs/server/runtime.js:37:33)
W20240322-10:25:49.037(-4)? (STDERR)     at Function.Module._load (internal/modules/cjs/loader.js:821:12)
W20240322-10:25:49.037(-4)? (STDERR)     at Module.require (internal/modules/cjs/loader.js:1005:19)
W20240322-10:25:49.038(-4)? (STDERR)     at require (internal/modules/cjs/helpers.js:107:18)
W20240322-10:25:49.038(-4)? (STDERR)     at Object.<anonymous> (/Users/x/node_modules/modern-syslog/index.js:9:12)
W20240322-10:25:49.038(-4)? (STDERR)     at Module._compile (internal/modules/cjs/loader.js:1116:14)
W20240322-10:25:49.038(-4)? (STDERR)     at Module.Mp._compile (/Users/x/.meteor/local/build/programs/server/runtime.js:77:23)
W20240322-10:25:49.038(-4)? (STDERR)     at Object.Module._extensions..js (/Users/x/.meteor/local/build/programs/server/runtime.js:105:23)
W20240322-10:25:49.038(-4)? (STDERR)     at Module.load (internal/modules/cjs/loader.js:981:32)
W20240322-10:25:49.038(-4)? (STDERR)     at Module.Mp.load (/Users/x/.meteor/local/build/programs/server/runtime.js:37:33)
W20240322-10:25:49.038(-4)? (STDERR)     at Function.Module._load (internal/modules/cjs/loader.js:821:12)
W20240322-10:25:49.038(-4)? (STDERR)     at Module.require (internal/modules/cjs/loader.js:1005:19)
W20240322-10:25:49.038(-4)? (STDERR)     at require (internal/modules/cjs/helpers.js:107:18)
W20240322-10:25:49.038(-4)? (STDERR)     at Object.<anonymous> (/Users/x/node_modules/filog/lib/Senders/SyslogSender.js:13:21) {
W20240322-10:25:49.038(-4)? (STDERR)   code: 'ERR_DLOPEN_FAILED'
W20240322-10:25:49.038(-4)? (STDERR) }
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

I can determine the architecture used in this file with the following:

% file node_modules/modern-syslog/build/Release/obj.target/core/core.o
node_modules/modern-syslog/build/Release/obj.target/core/core.o: Mach-O 64-bit object x86_64

I do not see any documentation or information about how to pass a flag to determine which architecture to use in this build?

msimerson commented 4 months ago

What version of node, and more importantly, node-gyp? I bet if you install newer versions of both, the problem goes away. It works on my M1 MBP.

❯ node -v
v21.6.1
❯ uname -a
Darwin mbp.simerson.net 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000 arm64
❯ file build/Release/obj.target/core/core.o
build/Release/obj.target/core/core.o: LLVM bitcode, wrapper