brianc / node-libpq

Simple, low level native bindings to PostgreSQL's libpq from node.js
111 stars 41 forks source link

libpq/build/Release/addon.node, 1): no suitable image found. Apple Silicon M1 issue? #81

Closed YoungiiJC closed 3 years ago

YoungiiJC commented 3 years ago

SOLVED: For anyone who lands here. I solved this by deleting and reinstalling node_modules under the Rosetta 2 terminal. I had run yarn install in the M1 terminal, and was trying to call the program from Rosetta 2... 💀

Hey there. I'm getting the following error while trying to run a script on the new M1 Apple silicon. The error message is different for node 12 and node 14.

Any help here? I've done the whole download homebrew with rosetta ordeal, and am calling this script from both an M1 and Rosetta instance of iTerm. Same error messages.

Also – I'm not sure if this is the correct place for this. I'm also posting to pg.

With Node v12.20.1:

/Users/daddy/Dev/scrape-project-sunroof/node_modules/pg/lib/index.js:41
          throw err
          ^

Error: dlopen(/Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/build/Release/addon.node, 1): no suitable image found.  Did find:
    /Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/build/Release/addon.node: mach-o, but wrong architecture
    /Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/build/Release/addon.node: mach-o, but wrong architecture
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at bindings (/Users/daddy/Dev/scrape-project-sunroof/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/index.js:1:46)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module._compile (/Users/daddy/Dev/scrape-project-sunroof/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.newLoader [as .js] (/Users/daddy/Dev/scrape-project-sunroof/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/daddy/Dev/scrape-project-sunroof/node_modules/pg-native/index.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Module._compile (/Users/daddy/Dev/scrape-project-sunroof/node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Object.newLoader [as .js] (/Users/daddy/Dev/scrape-project-sunroof/node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

With node v14.15.4

dyld: lazy symbol binding failed: Symbol not found: _PQconnectdb
  Referenced from: /Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/build/Release/addon.node
  Expected in: flat namespace

dyld: Symbol not found: _PQconnectdb
  Referenced from: /Users/daddy/Dev/scrape-project-sunroof/node_modules/libpq/build/Release/addon.node
  Expected in: flat namespace

error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.