节点 sqlite node-gyp 构建错误:“v8::Object”中没有名为“ForceSet”的成员

Posted

技术标签:

【中文标题】节点 sqlite node-gyp 构建错误:“v8::Object”中没有名为“ForceSet”的成员【英文标题】:Node sqlite node-gyp build error: no member named 'ForceSet' in 'v8::Object' 【发布时间】:2018-10-11 05:00:17 【问题描述】:

我在尝试安装依赖于 sqlite3 的全局包时遇到构建错误。我不太确定如何调试这样的节点构建错误,因此感谢您的帮助。通过搜索,我可以看出至少 xcode 错误不是问题。

我最近更新了 OSSierra 和 Node

OSSierra: 10.13.4
Node: 10.0.0
Yarn: 1.6.0

我这次运行的命令。我在全局安装其他包时遇到了同样的错误,所以我认为确切的 npm 包并不重要......

$ yarn global add import-js

错误

yarn global v1.6.0
(node:17489) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] ????  Resolving packages...
[2/4] ????  Fetching packages...
[3/4] ????  Linking dependencies...
warning "gatsby > friendly-errors-webpack-plugin@1.7.0" has incorrect peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning "gatsby > postcss-cssnext@2.11.0" has unmet peer dependency "caniuse-db@^1.0.30000652".
[4/4] ????  Building fresh packages...
[-/2] ⠂ waiting...
[2/2] ⠂ sqlite3: node-pre-gyp
[-/2] ⠂ waiting...
[-/2] ⠂ waiting...
error /Users/Jeff/.config/yarn/global/node_modules/sqlite3: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /Users/Jeff/.config/yarn/global/node_modules/sqlite3
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.39
node-pre-gyp info using node@10.0.0 | darwin | x64
node-pre-gyp info check checked for "/Users/Jeff/.config/yarn/global/node_modules/sqlite3/lib/binding/node-v64-darwin-x64/node_sqlite3.node" (not found)
node-pre-gyp http GET https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-darwin-x64.tar.gz
node-pre-gyp http 403 https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-darwin-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for sqlite3@3.1.13 and node@10.0.0 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-darwin-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@10.0.0 | darwin | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@10.0.0 | darwin | x64
gyp info spawn /usr/bin/python
gyp info spawn args [ '/usr/local/Cellar/node/10.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Jeff/.config/yarn/global/node_modules/sqlite3/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/Cellar/node/10.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/Jeff/.node-gyp/10.0.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/Jeff/.node-gyp/10.0.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/Cellar/node/10.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/Jeff/.node-gyp/10.0.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/Jeff/.config/yarn/global/node_modules/sqlite3',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@10.0.0 | darwin | x64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c
  TOUCH Release/obj.target/deps/action_before_build.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3150000/sqlite3.o
  LIBTOOL-STATIC Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
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);
         ~~~  ^
In file included from ../src/database.cc:4:
In file included from ../src/database.h:10:
../../nan/nan.h:834:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:171:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../src/database.cc:4:
In file included from ../src/database.h:10:
../../nan/nan.h:849:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:164:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../src/database.cc:4:
In file included from ../src/database.h:10:
../../nan/nan.h:864:18: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return node::MakeCallback(
                 ^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:157:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
In file included from ../src/database.cc:4:
In file included from ../src/database.h:10:
../../nan/nan.h:1473:31: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations]
    return scope.Escape(node::MakeCallback(
                              ^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:171:1: note: 'MakeCallback' has been explicitly marked deprecated here
NODE_DEPRECATED("Use MakeCallback(..., async_context)",
^
/Users/Jeff/.node-gyp/10.0.0/include/node/node.h:88:20: note: expanded from macro 'NODE_DEPRECATED'
    __attribute__((deprecated(message))) declarator
                   ^
../src/database.cc:144:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:230:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:525:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
../src/database.cc:625:9: warning: unused variable 'status' [-Wunused-variable]
    int status = uv_queue_work(uv_default_loop(),
        ^
8 warnings and 1 error generated.
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/Cellar/node/10.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:225:12)
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/Cellar/node/10.0.0/bin/node" "/usr/local/Cellar/node/10.0.0/libexec/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/Jeff/.config/yarn/global/node_modules/sqlite3/lib/binding/node-v64-darwin-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/Users/Jeff/.config/yarn/global/node_modules/sqlite3/lib/binding/node-v64-darwin-x64"
gyp ERR! cwd /Users/Jeff/.config/yarn/global/node_modules/sqlite3
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp build --fallback-to-build --module=/Users/Jeff/.config/yarn/global/node_modules/sqlite3/lib/binding/node-v64-darwin-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/Users/Jeff/.config/yarn/global/node_modules/sqlite3/lib/binding/node-v64-darwin-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/Jeff/.config/yarn/global/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:947:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:236:5)
node-pre-gyp ERR! System Darwin 17.5.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/10.0.0/bin/node" "/Users/Jeff/.config/yarn/global/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/Jeff/.config/yarn/global/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.0.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.39




 Jeff  …  global  ERROR  $   yarn version
yarn version v1.6.0
(node:17733) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
error An unexpected error occurred: "canceled".
info If you think this is a bug, please open a bug report with the information provided in "/Users/Jeff/.config/yarn/global/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/version for documentation about this command.

【问题讨论】:

【参考方案1】:

大部分日志只是弃用警告的噪音,但导致这种情况的单个错误是:

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);
         ~~~  ^

这里的问题是,V8 在 Node 10 使用的 V8 版本中删除了 ForceSet 方法,而这又是 nan 模块使用的方法。 nan 尚未赶上 V8 中的重大变化。

您尝试安装的import-js 软件包取决于^3.1.12 的版本sqlite3。由于 sqlite3 的公共 API 在版本 4 和 3 之间没有重大更改,因此您应该能够覆盖 import-js 所依赖的 sqlite3 版本。 3.1.134.0.0的区别可以看here。

要覆盖import-jssqlite3 版本,您可以在~/config/yarn/global/package.json 中添加选择性版本解析块:

...
"resolutions": 
  "import-js/**/sqlite3": "^4.0.0"
,
...

然后,yarn global remove import-js 后跟 yarn global add import-js。它可以在我的 Sierra 和基于 Linux 的操作系统上编译。我不保证一切都会完美无缺,但理论上应该如此,因为sqlite3 没有重大的 API 更改。

【讨论】:

我明白了。我认为这与这些线路有关,但我找不到合适的问题。当我愿意尝试时,我会尝试并接受【参考方案2】:

快速解决方案

从节点 10.x 降级到上一个节点 LTS 8.x:https://github.com/nodejs/Release

如果您使用的是 NVM,这很简单,您应该这样做:https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version/1115255#1115255

正确的解决方案:升级依赖以使用nan 版本>= v2.8.0

您可能有一个依赖于不支持节点 10.x 的旧版本 nan 包的依赖项。

首先通过阅读日志找到失败的包,或者使用:How to view the dependency tree of a given npm module?

这似乎是去掉 ForceSet 的 nan 版本:

commit 95cbb976d6fbbba88ba0f86dd188223a8591b4e7
Author: Benjamin Byholm <bbyholm@abo.fi>
Date:   Wed Nov 1 01:10:24 2017 +0200

    Use DefineOwnProperty instead of ForceSet

https://github.com/nodejs/nan/commit/95cbb976d6fbbba88ba0f86dd188223a8591b4e7

使用:How to list all tags that contain a commit?,我们看到此提交进入:v2.8.0

因此,您需要管理您的依赖项,以便所有内容都使用比 v2.8.0 更新的 nan。

然后将.nvmrc 添加到您的项目中,以向人们表明您使用的Node 版本as explained here。

node-sass 是最近给我带来问题的一个,看起来 node 10 只支持 node-sass 4.9:

https://github.com/sass/node-sass/issues/2345 https://github.com/sass/node-sass/issues/2551

什么是nan

nan 是一个可移植性帮助程序包,用于维护原生节点包的 v8 API 更稳定。

它包含在deps/v8的节点源代码中

所以不久前,v8 肯定已经放弃了ForceSet。为了便于携带,nan 必须保留它更长的时间。但最终,甚至 nan 也决定是时候删除它了。

相关问题

这些似乎有相同的根本原因:

No member named ForceSet How to install node-red-admin for node-red?

【讨论】:

【参考方案3】:

对于那些遇到npm 问题的人,库nannode v10 之间存在问题,已在nan@2.1.0 中解决。所以卸载nan并安装最新版本即可解决问题:

npm uninstall nan
npm install https://github.com/nodejs/nan
npm install <package-name>

【讨论】:

以上是关于节点 sqlite node-gyp 构建错误:“v8::Object”中没有名为“ForceSet”的成员的主要内容,如果未能解决你的问题,请参考以下文章

构建节点 gyp 时出错

Heroku:错误:找不到模块 node-gyp

节点 10 - npm 安装期间的“node-gyp 重建”错误

node-gyp 构建错误窗口 x64

为 npm 整数安装 node-gyp 错误

尝试构建“node-gyp configure”时堆栈“错误:证书链中的自签名证书”