nan: Electron 33 broken

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 {
      |                 ^~~~~~~~~~~~

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@danielweck this issue is still valid and should be open until a fix is landed

@danielweck could you share your package.json script with postinstall

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"

While the issue is solved in nan v2.22.2 postinstall overrides can be easily applied for sub dependencies. Here is a sample script from my repo:

updatenan.js

const spawn = require('child_process').spawn
const existsSync = require('fs').existsSync
const nanPath = existsSync('./node_modules/nan/nan.h') ? './node_modules/nan/nan.h' : '../nan/nan.h'

if(existsSync(nanPath)){
    if (process.platform === 'win32') {
        spawn('powershell', ['-Command', `(Get-Content -Raw ${nanPath}) -replace '#include \"nan_scriptorigin.h\"', '// #include \"nan_scriptorigin.h\"' | Out-File -Encoding Utf8 ${nanPath}`], { stdio: 'inherit' })
    } else {
        spawn('sed', ['-i', '-e', 's/^#include .nan_scriptorigin\\.h./\\/\\/ #include nan_scriptorigin.h/', nanPath], { stdio: 'inherit' })
    }

}

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 nan will address the issue themselves.