Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm i failing on Node 20 on Mac OSX #157

Open
mrhornsby opened this issue Jan 22, 2024 · 0 comments
Open

npm i failing on Node 20 on Mac OSX #157

mrhornsby opened this issue Jan 22, 2024 · 0 comments

Comments

@mrhornsby
Copy link

mrhornsby commented Jan 22, 2024

Hi,

Thanks for the great project, I've been using it for a number of years.

I recently ran in to a problem when upgrading to Node.js 20. On running npm i on a dependent project it fails to to install graphene-pk11-2.3.2 due to a handful of node-gyp errors (these appear to be coming from the pkcs11js dependency, so maybe I should raise the query on that project of yours instead?):

npm ERR! /Users/mark/Library/Caches/node-gyp/20.11.0/include/node/v8-maybe.h:123:67: error: expected '(' for function-style cast or type construction
npm ERR! template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! /Users/mark/Library/Caches/node-gyp/20.11.0/include/node/v8-maybe.h:106:69: error: expected '(' for function-style cast or type construction
npm ERR!   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
npm ERR!                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
npm ERR! /Users/mark/Library/Caches/node-gyp/20.11.0/include/node/v8-maybe.h:123:43: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
npm ERR! template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>
npm ERR! /Users/mark/Library/Caches/node-gyp/20.11.0/include/node/v8-maybe.h:106:45: error: no template named 'is_lvalue_reference_v' in namespace 'std'; did you mean 'is_lvalue_reference'?
npm ERR!   template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>

After a bit of poking around I determined that is_lvalue_reference_v appears to be a C++17 feature which is just a call to is_lvalue_reference and then ::value on the result so I hacked my local cache of v8 headers and everything works as expected i.e. change:

template <class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>

to:

template <class U, std::enable_if_t<!std::is_lvalue_reference<U>::value>*>

and:

template <class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* = nullptr>

to:

template <class T, std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr>

in /Users/mark/Library/Caches/node-gyp/20.11.0/include/node/v8-maybe.h.

Afraid this isn't my area of expertise, but I'm guessing that you might be able to pass the C++17 flags in to node-gyp to avoid having to make these changes to the v8 headers?

For reference I'm using:

Mac OSX 14.2.1
Node.js 20.11.0 (through Homebrew)
[email protected]
Apple clang version 15.0.0 (clang-1500.1.0.2.5)

Thanks

Mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant