Node sqlite node-gyp build error: no member named 'ForceSet' in 'v8::Object'
Most of the log is just noise of deprecation warnings, but the single error that causes this is:
In file included from ../src/database.cc:4:
In file included from ../src/database.h:10:
In file included from ../../nan/nan.h:192:
../../nan/nan_maybe_43_inl.h:112:15: error: no member named 'ForceSet' in 'v8::Object'
return obj->ForceSet(isolate->GetCurrentContext(), key, value, attribs);
~~~ ^
The problem here is that V8 has removed ForceSet
method in the V8 version that Node 10 uses, which in turn is what the nan
module uses. nan
has not yet caught up to the breaking changes in V8.
The import-js
package you're trying to install depends on version ^3.1.12
of sqlite3
. Since there are no breaking changes in sqlite3
's public API between version 4 and 3, you should be able to override the version of sqlite3
that import-js
depend on. The difference between 3.1.13
and 4.0.0
can be seen here.
To override import-js
's version of sqlite3
, you can add a selective version resolution-block to your ~/config/yarn/global/package.json
:
...
"resolutions": {
"import-js/**/sqlite3": "^4.0.0"
},
...
And afterwards, yarn global remove import-js
followed by yarn global add import-js
. It does compile on my Sierra as well as my Linux-based OS. I'm not guaranteeing that everything will work flawlessly, but in theory it should as there are no breaking API changes to sqlite3
.
Quick solution
Downgrade from node 10.x to the previous node LTS 8.x: https://github.com/nodejs/Release
This is trivial if you are using NVM, which you should: https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version/1115255#1115255
Correct solution: upgrade the dependencies to use nan
version >= v2.8.0
You likely have a dependency that depends on an older version of the nan
package that does not support node 10.x.
First find the failing package by reading the logs, or use: How to view the dependency tree of a given npm module?
This seems to be the version of nan that removed ForceSet:
commit 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
Author: Benjamin Byholm <[email protected]>
Date: Wed Nov 1 01:10:24 2017 +0200
Use DefineOwnProperty instead of ForceSet
https://github.com/nodejs/nan/commit/95cbb976d6fbbba88ba0f86dd188223a8591b4e7
With: How to list all tags that contain a commit? we see that this commit went into: v2.8.0
So, you need to manage your dependencies such that everything uses nan newer than v2.8.0.
And then add an .nvmrc
to your project to indicate to people what version of Node you tested with, as explained here.
node-sass is one that caused problems to me recently, it looks like node 10 is only supported as of node-sass 4.9:
- https://github.com/sass/node-sass/issues/2345
- https://github.com/sass/node-sass/issues/2551
What is nan
?
nan
is a portability helper package to maintain the v8 API more stable for native node packages.
It is included in the node source code at deps/v8
So a while back, v8 must have dropped ForceSet
. nan must have kept it for a longer time for portability. But eventually even nan decided it was time to remove it.
Related issues
Those seem to have the same root cause:
- No member named ForceSet
- How to install node-red-admin for node-red?