question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node-API (`nApi` feature flag) not working on Apple Silicon / MacOS ARM M1

See original GitHub issue

Bug description

The preview feature nApi is not working on Apple Silicon devices. By directly loading the .node binary using plain require(), I found that the binary isn’t for ARM64. Here’s the log with personal info removed.

> const prismaEngine = require('./prisma/libquery_engine_napi-darwin.dylib.node')
Uncaught:
Error: dlopen(/.../prisma/libquery_engine_napi-darwin.dylib.node, 1): no suitable image found.  Did find:
        /.../prisma/libquery_engine_napi-darwin.dylib.node: mach-o, but wrong architecture
        /.../prisma/libquery_engine_napi-darwin.dylib.node: mach-o, but wrong architecture
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1167:18)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:997:19)
    at require (node:internal/modules/cjs/helpers:92:18) {
  code: 'ERR_DLOPEN_FAILED'
}

I believe that it’s just not yet supported as it’s currently in the preview stage. However, I’m opening this since I found no tracking issue for Apple Silicon support of nApi feature.

How to reproduce

  1. Run prisma generate to generate the client and the engine.
  2. Load the client
  3. Error occurs

Expected behavior

No response

Prisma information

generator client {
  provider        = "prisma-client-js"
  output          = "."
  previewFeatures = ["nApi"]
}

...

Environment & setup

  • OS: macOS 11.2.3 on M1 Macbook Air
  • Node.js version: v15.5.0

Prisma Version

prisma               : 2.23.0
@prisma/client       : 2.23.0
Current platform     : darwin
Query Engine         : query-engine adf5e8cba3daf12d456d911d72b6e9418681b28b (at ../../node_modules/@prisma/engines/query-engine-darwin)
Migration Engine     : migration-engine-cli adf5e8cba3daf12d456d911d72b6e9418681b28b (at ../../node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core adf5e8cba3daf12d456d911d72b6e9418681b28b (at ../../node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary        : prisma-fmt adf5e8cba3daf12d456d911d72b6e9418681b28b (at ../../node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : adf5e8cba3daf12d456d911d72b6e9418681b28b
Studio               : 0.393.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
janpiocommented, Jun 3, 2021

Until that happens we will exclude M1/Apple Silicon from using Node API libraries in CLI and Client. Follow the implementation of that here: https://github.com/prisma/prisma/issues/7431 This will ensure you can work with Prisma.

3reactions
pantharshit00commented, Jun 1, 2021

We don’t really have a native build for Apple Silicon. The current version binaries works via Rosetta.

This is somewhat a duplicate of https://github.com/prisma/prisma/issues/5245 but I think with Node API this needs more attention and we should spend time setting up the CI for building these binaries.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Addressing Architectural Differences in Your macOS Code
Fix problems that stem from architectural differences between Apple silicon and Intel-based Mac computers.
Read more >
Porting Your macOS Apps to Apple Silicon
Port your existing macOS app to Apple silicon by creating a universal binary and modifying your code to handle architectural differences.
Read more >
Use macOS Recovery on a Mac with Apple silicon
In the Recovery app, select Reinstall macOS Ventura, then click Continue. To return to the Recovery app, choose Install macOS Ventura > Quit...
Read more >
Porting Your Metal Code to Apple Silicon
How you port a Metal app to a Mac with Apple silicon depends on whether your ... To expedite fixing your app, this...
Read more >
Running your iOS apps in macOS - Apple Developer
Modernize the iOS apps you choose to run on a Mac with Apple silicon, ... on features available only on iOS devices, you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found