nodejs / nan

Native Abstractions for Node.js
MIT License
3.27k stars 501 forks source link

Error when building NAN modules targeting Electron 31.0.0-beta.8 ('CopyablePersistentTraits': is not a member of 'v8') #969

Closed andreasdj closed 2 months ago

andreasdj commented 3 months ago

Building node modules dependent on NAN stops working between the Electron versions 31.0.0-nightly.20240412 and 31.0.0-alpha.1. Between those versions chromium/v8 has been updated to from 124/12.4 to 125/12.5 and node from v20.11.1 to v20.12.2.

The following error is reported:

node_modules\nan\nan.h(211,47): error C2039: 'CopyablePersistentTraits': is not a member of 'v8'

I can see that CopyablePersistantTraits is marked as deprecated in the v8 source code for node 20, is that the reason? https://v8docs.nodesource.com/node-20.3/da/d1f/v8-persistent-handle_8h_source.html#l00258

Following the deprecation message Use v8::Global instead solves the build issue but I know to little to know if that's the correct solution. An updated node version check before setting class CopyablePersistentTraits is also needed together with such an update.

agracio commented 2 months ago

Electron 31.0.0 is now officially released and the issue persists since CopyablePersistentTraits has been deprecated. Are there any plans to update nan to deal with this issue?

kkoopa commented 2 months ago

Could you confirm that the linked PR fixes the issue?

andreasdj commented 2 months ago

I can confirm that the linked PR fixes the issue 👍. It's possible to build node modules using nan targeting electron 31.