Skip to content

[node 20] Compilation error on nan #273

Closed

Description

@yosiat

Hi,

I am trying to upgrade to node 20 (from 16) and I see this compilation error:

npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]

npm ERR! In file included from ../../nan/nan.h:178,

npm ERR!                  from ../bindings/profiler.cc:19:

npm ERR! ../../nan/nan_callbacks.h:55:23: error: 'AccessorSignature' is not a member of 'v8'

npm ERR!    55 | typedef v8::Local<v8::AccessorSignature> Sig;

npm ERR!       |                       ^~~~~~~~~~~~~~~~~

npm ERR! ../../nan/nan_callbacks.h:55:40: error: template argument 1 is invalid

npm ERR!    55 | typedef v8::Local<v8::AccessorSignature> Sig;

npm ERR!       |                                        ^

npm ERR! ../../nan/nan.h: In function 'bool Nan::IdleNotification(int)':

npm ERR! ../../nan/nan.h:684:63: warning: 'bool v8::Isolate::IdleNotificationDeadline(double)' is deprecated: Use MemoryPressureNotification() to influence the GC schedule. [-Wdeprecated-declarations]

npm ERR!   684 |     return v8::Isolate::GetCurrent()->IdleNotificationDeadline(

npm ERR!       |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

npm ERR!   685 |         idle_time_in_ms * 0.001);

npm ERR!       |         ~~~~~~~~~~~~~~~~~~~~~~~~                               

npm ERR! In file included from /home/node/.cache/node-gyp/20.10.0/include/node/v8-initialization.h:13,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/v8.h:34,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/node.h:73,

npm ERR!                  from ../../nan/nan.h:58:

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-isolate.h:1293:8: note: declared here

npm ERR!  1293 |   bool IdleNotificationDeadline(double deadline_in_seconds);

npm ERR!       |        ^~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! ../../nan/nan.h: In function 'void Nan::SetAccessor(v8::Local<v8::ObjectTemplate>, v8::Local<v8::String>, GetterCallback, SetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, imp::Sig)':

npm ERR! ../../nan/nan.h:2544:19: error: no matching function for call to 'v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>&, void (*&)(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&), void (*&)(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&), v8::Local<v8::Object>&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)'

npm ERR!  2544 |   tpl->SetAccessor(

npm ERR!       |   ~~~~~~~~~~~~~~~~^

npm ERR!  2545 |       name

npm ERR!       |       ~~~~         

npm ERR!  2546 |     , getter_

npm ERR!       |     ~~~~~~~~~      

npm ERR!  2547 |     , setter_

npm ERR!       |     ~~~~~~~~~      

npm ERR!  2548 |     , obj

npm ERR!       |     ~~~~~          

npm ERR!  2549 |     , settings

npm ERR!       |     ~~~~~~~~~~     

npm ERR!  2550 |     , attribute

npm ERR!       |     ~~~~~~~~~~~    

npm ERR!  2551 |     , signature);

npm ERR!       |     ~~~~~~~~~~~~   

npm ERR! In file included from /home/node/.cache/node-gyp/20.10.0/include/node/v8-function.h:15,

npm ERR!                  from /home/node/.cache/node-gyp/20.10.0/include/node/v8.h:33:

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:809:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Local<v8::String>, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'

npm ERR!   809 |   void SetAccessor(

npm ERR!       |        ^~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:814:22: note:   no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'

npm ERR!   814 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,

npm ERR!       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:816:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Local<v8::Name>, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Local<v8::Value>, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'

npm ERR!   816 |   void SetAccessor(

npm ERR!       |        ^~~~~~~~~~~

npm ERR! /home/node/.cache/node-gyp/20.10.0/include/node/v8-template.h:821:22: note:   no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'

npm ERR!   821 |       SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,

npm ERR!       |       ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

npm ERR! make: *** [pprof.target.mk:115: Release/obj.target/pprof/bindings/profiler.o] Error 1

npm ERR! gyp ERR! build error 

This issue looks like it's fixed in nan 2.17.0 - https://github.com/nodejs/nan/blob/main/CHANGELOG.md#2170-oct-10-2022

Is it possible to upgrade this dependency?

Activity

  1. aabmass commented on Dec 5, 2023

    @aabmass
    Member

    Thanks for flagging this. It's actually fixed on main, we just need a release.

  2. self-assigned this
    on Dec 5, 2023
  3. yosiat commented on Dec 7, 2023

    @yosiat
    Author

    Thanks @aabmass , I saw it was released as 3.3.0 which is deprecated release.

  4. aabmass commented on Dec 13, 2023

    @aabmass
    Member

    Yes, I deprecated that one. IIRC it contained accidental breaking changes which should have been a major bump. I made a patch release instead to fix it

  5. yosiat commented on Jan 28, 2024

    @yosiat
    Author

    hey @aabmass is there any update on this one?

    we are blocked on node 18 because of this, and the fix should be simple (unless I am missing something) - change nan from 2.14.0 to 2.17.0

  6. aabmass commented on Jan 31, 2024

    @aabmass
    Member

    @yosiat I'm working on a release right now. However, after checking what was published in pprof@3.2.1, I notice the version of nan has a carat dependency:

    "nan": "^2.14.0",

    IOW, you should be able to install it in Node 20 today. You might have an older version of nan in your package-lock.json. Please try upgrading nan–I tested it in a fresh repo and it works.

  7. yosiat commented on Feb 1, 2024

    @yosiat
    Author

    @aabmass I agree with you that carat should work here, but it doesn't work as expected in my project.

    It keeps installing nan v2.15.0 (and there is no other module depending on it except pprof), the only trick that worked is npm install nan and then npm uninstall nan, which is a bit weird one.

  8. aabmass commented on Feb 2, 2024

    @aabmass
    Member

    @yosiat I'm guessing it was probably stale from either your package-lock.json or in node_modules directory

  9. aabmass commented on Feb 2, 2024

    @aabmass
    Member

    Just published v4.0.0

  10. yosiat commented on Feb 3, 2024

    @yosiat
    Author

    Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions