Repository navigation
Closed
Description
The latest NAN release works fine in Electron 32, but now fails with:
In file included from ../node_modules/nan/nan.h:3045:
../node_modules/nan/nan_scriptorigin.h:40:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
40 | v8::ScriptOrigin(v8::Isolate::GetCurrent()
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
41 | , name
| ~~~~~~
42 | , To<int32_t>(line).FromMaybe(0)) {}
../node_modules/nan/nan_scriptorigin.h:47:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
47 | v8::ScriptOrigin(v8::Isolate::GetCurrent()
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
48 | , name
| ~~~~~~
49 | , To<int32_t>(line).FromMaybe(0)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 | , To<int32_t>(column).FromMaybe(0)) {}
../node_modules/nan/nan_scriptorigin.h:36:7: error: no matching constructor for initialization of 'v8::ScriptOrigin'
36 | v8::ScriptOrigin(v8::Isolate::GetCurrent(), name) {}
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:64:13: note: candidate constructor not viable: no known conversion from 'Isolate *' to 'Local<Value>' for 1st argument
64 | V8_INLINE ScriptOrigin(Local<Value> resource_name,
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:62:17: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
62 | class V8_EXPORT ScriptOrigin {
| ^~~~~~~~~~~~
/Users/qwe/Library/Caches/node-gyp/33.0.0/include/node/v8-message.h:62:17: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
62 | class V8_EXPORT ScriptOrigin {
| ^~~~~~~~~~~~
Metadata
Metadata
Assignees
Labels
No labels
Activity
danielweck commentedon Oct 16, 2024
This follows the fix for Electron v32:
See: #973 (comment)
danielweck commentedon Oct 16, 2024
Electron 33 ships with Node 20.18.0:
https://github.com/electron/electron/releases/tag/v33.0.0
agracio commentedon Oct 16, 2024
Electron 33 moved to v8 13.0 while Node.js main is currently on v8 12.9, perhaps someone can create a working fork that addresses the problem?
Unless by some miracle Node.js moves to v8 13.0 for its v23 release I do not think
nanwill address the issue themselves.danielweck commentedon Oct 16, 2024
Great point @agracio ... pinging @toshiyuki-rs @oc-soft @kkoopa @bugsounet
agracio commentedon Oct 16, 2024
You should not ping
nanmaintainers as they have been quick to point out that they do not support and have no intention to support Electron in the future.danielweck commentedon Oct 16, 2024
Apologies, I thought you were the NAN maintainer :) 👍 (very quick response indeed, thank you)
Well, my workaround is to comment
#include nan_scriptorigin.hinnan.h:nan/nan.h
Line 3045 in f5921c7
(I do this with
sedfrom mypackage.jsonpostinstall)Closing the issue now.
kkoopa commentedon Oct 16, 2024
It is probably this commit. 0151569 I will get around to it at some future time.
agracio commentedon Oct 16, 2024
Thanks!
agracio commentedon Oct 16, 2024
@danielweck could you share your package.json script with postinstall
kkoopa commentedon Oct 16, 2024
And can someone with Electron 33 confirm that applying 0151569 resolves the issue?
agracio commentedon Oct 16, 2024
Will do but give me about 30+ minutes.
danielweck commentedon Oct 16, 2024
Not pretty, quick and dirty, but works in MacOS and Linux:
"postinstall": "sed 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/' ./node_modules/nan/nan.h > ./node_modules/nan/nan.h.new && mv ./node_modules/nan/nan.h.new ./node_modules/nan/nan.h"agracio commentedon Oct 16, 2024
It absolutely does, tested Electron 29, 30, 31, 32 and 33 that are supported by nan 2.22.
agracio commentedon Oct 17, 2024
@kkoopa So is it just a issue of merging that commit and everything will be working?
patch nan package for electron 33 - see nodejs/nan#978
Bump to Electron 33.
ayZagen commentedon Feb 9, 2025
@danielweck this issue is still valid and should be open until a fix is landed
agracio commentedon Feb 28, 2025
The issue is not present in nan v2.22.2 tested with electron 29-34 as well as 35 beta and latest 36 nightly.
oalfroukh commentedon Mar 2, 2025
Hi @danielweck
But thispostinstallwill not work fine in case usingnanby subDependencies, so I think this issue should be reopened as needs a fix...Anyone can take a look at it, please?
EDIT:
The issue is fixed on
nanv2.22.2sooverridesthe version to the latest version that's released 4 days ago(`v2.22.2) will fix the issue.agracio commentedon Mar 2, 2025
While the issue is solved in
nan v2.22.2postinstall overrides can be easily applied for sub dependencies.Here is a sample script from my repo:
updatenan.jsoalfroukh commentedon Mar 3, 2025
Also just adding
overridesto thepackage.jsonshould fix the issue for sub dependencies instead of using scriptsagracio commentedon Mar 3, 2025
I removed that script from my repo since the release of
nan v2.22.2just wanted to show a PoC of install/postinstall script that works for sub dependencies. Cannot even take a credit for it as it was a PR from one of the repo contributors.Build the engine on Node 22.23.3 from nodejs.org, checked by SHA-256