Enhancement: migrate from nan to node-addon-api (N-API)
See original GitHub issueI’m trying to use this with Electron
and run some tests in Node
but I absolutely cannot get a working version for each runtime working simultaneously. It always puts the built module into Release\sharp.node
, overwriting the previously built version.
If I build for electron, I cannot test. If I build for Node, I cannot run it in Electron.
When I build for Electron, my tests return the following:
The file it says it cannot find does exist
FAIL app/redux/sagas/firebase/oneTime/__tests__/helpers.test.js
● Test suite failed to run
The specified module could not be found.
\\?\C:\projects\myApp\app\node_modules\sharp\build\Release\sharp.node
Error: The specified module could not be found.
\\?\C:\projects\myApp\app\node_modules\sharp\build\Release\sharp.node
at Runtime.requireModule (node_modules/jest-runtime/build/index.js:372:31)
at Object.<anonymous> (app/node_modules/sharp/lib/constructor.js:10:15)
When I build for Node, my app’s renderer throws this error:
ELECTRON_ASAR.js:172 Uncaught Error: The system cannot find message text for message number 0x%1 in the message file for %2.
\\?\C:\projects\myApp\app\node_modules\sharp\build\Release\sharp.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:671:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:504:12)
at Function.Module._load (module.js:496:3)
at Module.require (module.js:586:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\projects\myApp\app\node_modules\sharp\lib\constructor.js:10:15)
at Object.<anonymous> (C:\projects\myApp\app\node_modules\sharp\lib\constructor.js:259:3)
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
NAN to Node-API Migration: A Short Story - NodeSource
Throughout the years I've created my fair share of native addons. The first ones were created by using the native C++ Node.js and...
Read more >Migration tutorial · The Node-API Resource - GitHub Pages
The objective of this tutorial is to give you a good idea of the steps necessary and the tools available to migrate an...
Read more >How We Migrated Realm JavaScript From NAN to N-API
The Realm JavaScript team has reimplemented the Realm JS Node.js SDK from the ground up to use N-API. Here we describe how and...
Read more >Asynchronous C++ Addon for Node.js with N-API ... - CodeMerx
This method overrides the Napi::AsyncWorker::Execute method and as such will be executed on a worker thread different than the Node.js event ...
Read more >Migrating old Addons to NAPI - node.js nan - Stack Overflow
n-api is a new way to create addon independent from the underlying JavaScript runtime (ex V8) and is maintained as part of Node.js....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
v0.25.0 now available with the use of N-API. I’m sure the maintainers of the many modules that depend upon sharp will be happy with the reduced level of installation issues this will bring.
Hello, this is more a current limitation of native modules in Node rather than being a problem specific to sharp.
Different versions of Node and Electron each have different ABIs, hence the need to ensure compilation occurred against the relevant runtime.
Node provides a new ABI-stable N-API that aims to solve this problem. To take advantage of this we need to: