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.

ffi-napi: An object was expected

See original GitHub issue

Prerequisites

Expected Behavior

ffi-napi should work fine within packaged app

Current Behavior

I added ref-napi (https://github.com/node-ffi-napi/ref-napi) (v. 2.1.2) as a native dependency. It works ok when running the app locally (even prod build), but as soon as I try to run a packaged and installed version of the app (both Windows and MacOS), the error from screenshot get raised image

Actually this line fails image

Invocation of the require('node-gyp-build')(path.join(__dirname, '..')) gives me the error listed above.

Steps to Reproduce

  1. Install ref-napi as a native dependency in the app directory

  2. Import and use ref-napi somewhere in renderer, e.g., any React component

  3. Run yarn cross-env DEBUG_PROD=true yarn package

  4. Install app

  5. Once the app launched, you can observe error in dev console

Context

Why: I’m using this package in conjunction with ffi-napi (https://github.com/node-ffi-napi/node-ffi-napi) to get access to the system’s libraries via FFI approach (C language) The main change: only added dotenv and utilized it in webpack configs

Your Environment

  • Node version : v12.18.2
  • electron-react-boilerplate version or branch : master
  • Operating System and version : MacOS Catalina 10.15.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
cohenshaycommented, Jan 4, 2021

changing the electron-rebuild script to work with --sequential instead of --parallel, solved the issue for me

0reactions
MD-AZMALcommented, Jan 5, 2021

@MD-AZMAL try using these versions:

“ffi-napi”: “^2.0.3”, “ref-napi”: “^1.5.2”

tried this faced the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Require ('ffi') throws error in Electron application
Received type object... The require('ffi') works as expected, for example, in this simple project. After some invesigation I have found, ...
Read more >
node-ffi-napi - Bountysource
how the issue happen: 1. in DLL, two thread running, and will give callbacks to JS side with preset interval(10ms) in every thread....
Read more >
ref-napi | Yarn - Package Manager
ref-napi. Turn Buffer instances into "pointers". Greenkeeper badge ... This module is inspired by the old Pointer class from node-ffi, but with the...
Read more >
ffi-napi - npm Package Health Analysis - Snyk
We found indications that ffi-napi is an Inactive project. See the full package health analysis to learn more about the package maintenance status....
Read more >
A Guide for JavaScript Developers to build C++ Add-ons with ...
Do you expect to reuse a third party C++ library in your Node.js project? ... Option 1 FFI: node-ffi OR node-ffi-napi.
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