Install fails using npm at error C2039: 'NamedPropertyGetterCallback'

I’m having trouble when installing Realm. It goes fine for a while, then errors out halfway with a list of errors (see below).

Windows 10 (also happening on my Win 7 laptop)

C:>node -v
v12.9.1

C:>npm -v
6.13.4

I’m following the recommended “Getting Started” steps

C:\rn> npx react-native init test

C:\rn> cd test

C:\rn\test> npm install --save realm

So, my question is … do I need a specific version of node or npm to make this work? I saw old threads stating node had to be between 7-8 or 10 … but they were 2 years old.


c:\rn\test\node_modules\realm\src\node\node_types.hpp(52): error C2039: NamedPropertyGetterCallback’: is not a member of ‘v8’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8-platform.h(16): note: see declaration of ‘v8’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_types.hpp(52): error C2061: syntax error: identifier ‘NamedPropertyGetterCallback’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_types.hpp(53): error C2039: ‘NamedPropertySetterCallback’: is not a member of ‘v8’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8-platform.h(16): note: see declaration of ‘v8’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_types.hpp(53): error C2061: syntax error: identifier ‘NamedPropertySetterCallback’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_types.hpp(54): error C2039: ‘NamedPropertyEnumeratorCallback’: is not a member of ‘v8’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8-platform.h(16): note: see declaration of ‘v8’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_types.hpp(54): error C2061: syntax error: identifier ‘NamedPropertyEnumeratorCallback’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_string.hpp(51): error C2660: ‘v8::String::Utf8Length’: function does not take 0 arguments (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8.h(2691): note: see declaration of ‘v8::String::Utf8 Length’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_string.hpp(53): error C2664: ‘int v8::String::WriteUtf8(v8::Isolate ,char,int,int *,int) const’: cannot convert argument 1 from ‘char *’ to ‘v8::Isolate *’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_string.hpp(53): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_object.hpp(33): error C2039: ‘ExternalOneByteStringResourceImpl’: is not a member of ‘v8’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8-platform.h(16): note: see declaration of ‘v8’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_object.hpp(33): error C2061: syntax error: identifier ‘ExternalOneByteStringResourceImpl’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_object.hpp(33): error C2660: ‘v8::String::NewExternal’: function does not take 1 arguments (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8.h(2971): note: see declaration of ‘v8::String::NewExternal’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_object.hpp(33): error C2143: syntax error: missing ‘;’ before ‘)’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_object.hpp(33): error C2059: syntax error: ‘)’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_object.hpp(108): error C2661: ‘v8::Value::ToString’: no overloaded function takes 0 arguments (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_function.hpp(41): error C2039: ‘GetCallingContext’: is not a member of ‘v8::Isolate’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\users\nate\appdata\local\node-gyp\cache\12.9.1\include\node\v8-platform.h(18): note: see declaration of ‘v8::Isolate’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_value.hpp(152): error C2661: ‘v8::Value::ToString’: no overloaded function takes 0 arguments (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(92): error C2039: ‘StringPropertyGetterCallback’: is not a member of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_types.hpp(38): note: see declaration of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\node\node_class.hpp(368): note: see reference to class template instantiation ‘realm::js::StringPropertyTyperealm::node::Types’ being compiled (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\js_class.hpp(92): error C3646: ‘getter’: unknown override specifier (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(92): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(93): error C2039: ‘StringPropertySetterCallback’: is not a member of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_types.hpp(38): note: see declaration of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\js_class.hpp(93): error C3646: ‘setter’: unknown override specifier (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(93): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(94): error C2039: ‘StringPropertyEnumeratorCallback’: is not a member of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\node\node_types.hpp(38): note: see declaration of ‘realm::node::Types’ (compiling source file …\src\node\node_init.cpp)
c:\rn\test\node_modules\realm\src\js_class.hpp(94): error C3646: ‘enumerator’: unknown override specifier (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
c:\rn\test\node_modules\realm\src\js_class.hpp(94): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file …\src\node\node_init.cpp) [C:\rn\test\node_modules\realm\build\realm.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\nate\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:209:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\nate\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “build” “–fallback-to-build” “–module=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64\realm.node” “–module_name=realm” “–module_path=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64” “–napi_version=4” “–node_abi_napi=napi” “–napi_build_version=0” “–node_napi_label=node-v72”
gyp ERR! cwd C:\rn\test\node_modules\realm
gyp ERR! node -v v12.9.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute ‘C:\Program Files\nodejs\node.exe C:\Users\nate\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64\realm.node --module_name=realm --module_path=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72’ (1)
node-pre-gyp ERR! stack at ChildProcess. (C:\rn\test\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:209:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.17763
node-pre-gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\rn\test\node_modules\node-pre-gyp\bin\node-pre-gyp” “install” “–fallback-to-build”
node-pre-gyp ERR! cwd C:\rn\test\node_modules\realm
node-pre-gyp ERR! node -v v12.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute ‘C:\Program Files\nodejs\node.exe C:\Users\nate\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64\realm.node --module_name=realm --module_path=C:\rn\test\node_modules\realm\compiled\node-v72_win32_x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72’ (1)
npm WARN @typescript-eslint/eslint-plugin@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @typescript-eslint/parser@1.13.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! realm@3.6.3 install: node-pre-gyp install --fallback-to-build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the realm@3.6.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\nate\AppData\Roaming\npm-cache_logs\2020-01-20T13_19_33_755Z-debug.log

Hi,

Supported Node versions are listed in the Realm JavaScript SDK docs, which currently only includes the Node 8.x and 10.x LTS releases. I would recommend using the latest Node 10.x release if you are starting a new project.

Support for Node 12 (and beyond) using Node’s N-API for native add-ons is currently in progress. N-API provides a stable interface for native add-ons so they can be compiled once per platform and architecture and be available for any version of the Node LTS runtime that implements N-API.

For updates you can subscribe to realm-js issue #2516 on GitHub.

Regards,
Stennie

Thanks … had to uninstall node.js completely from Windows (tried to use nvmw to switch node versions, but it didn’t work) and then re-installed v10.18

installed node-v10.18.1-x64.msi from https://nodejs.org/dist/latest-v10.x/

then ran the npm install realm and react-native link realm commands and all seems to be working … now to get some code working :slight_smile: