joeferner / node-java

Bridge API to connect with existing Java APIs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with M1 ARM Architecture

baubakg opened this issue · comments

Hi There,

Just wanted to give the thumbs up about the node-java project and the M1-ARM Mac architecture.

Since I recently changed my computer to M1 ARM64 I started getting the error:

node:internal/modules/cjs/loader:1210
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen(/Users/me/pathToProject/simpleJSToJava/node_modules/java/build/Release/nodejavabridge_bindings.node, 0x0001): tried: 'Users/me/pathToProject/simpleJSToJava/node_modules/java/build/Release/nodejavabridge_bindings.node' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/gandomi/Documents/development/misc/cypress/cypress-maven/simpleJSToJava/node_modules/java/lib/nodeJavaBridge.js:21:16)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
  code: 'ERR_DLOPEN_FAILED'
}

I did however solve this by:

  1. Installing rosetta
  2. Start terminal with Rosetta
  3. re-Install x86 nodejs
  4. reset installation npm ci
  5. reinstall node java npm install java

I do not know if you plan to get this to work on arm64, but here is the workaround.