1

在安装 libcouchbase 之后,我执行了

sudo npm install couchbase

它报错:

npm WARN cannot run in wd couchbase@1.2.4 (node-gyp rebuild 2> builderror.log) || (exit 0) (wd=/Users/mymac/node_modules/couchbase)

然后我去了 node_modules/couchbase 并执行

npm install

它输出了日志错误:

../deps/lcb/src/compat.c:194:36: warning: missing field 'v' initializer [-Wmissing-field-initializers]
    struct lcb_create_st cst = { 0 };
                                   ^
1 warning generated.
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
../src/logger.h: In instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]':
../src/logger.h:74:   instantiated from here
../src/logger.h:74: error: explicit instantiation of 'std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' but no definition available
make: *** [Release/obj.target/couchbase_impl/src/couchbase_impl.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/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:807:12)
gyp ERR! System Darwin 12.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/couchbase
gyp ERR! node -v v0.10.28
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 

看起来 node-gyp 无法正确编译源代码

如果我使用代码

 var couchbase = require('couchbase');
 var db = new couchbase.Connection({
     bucket: "default"

 },
 function(err) {
     if (err) throw err;
     db.set('testdoc1', {
         name: 'Frank1'
     }, function(err, result) {
         if (err) throw err;
         db.get('testdoc1', function(err, result) {
             if (err) throw err;
             console.log(result.value);
             // {name: Frank}
         });
     });
 });

控制台报告

Users/mymac/node_modules/couchbase/lib/binding.js:17
      throw e;
            ^
Error: dlopen(/Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node, 1): no suitable image found.  Did find:
    /Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node: unknown file type, first eight bytes: 0x4D 0x5A 0x90 0x00 0x03 0x00 0x00 0x00
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at bindings (/Users/mymac/node_modules/couchbase/node_modules/bindings/bindings.js:74:15)
    at tryLoadBinding (/Users/mymac/node_modules/couchbase/lib/binding.js:13:31)
    at Object.<anonymous> (/Users/mymac/node_modules/couchbase/lib/binding.js:31:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

它找不到正确的couchbase_impl.node(什么都没有)

在此处输入图像描述

所以它会预先构建并获得错误的平台版本

/Users/mymac/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node

我尝试在centos,ubuntu上安装couchnode,甚至在1年前在osx相同的mac上安装没有任何问题。

我不确定我是否在做其他工作时将 gcc 之类的东西/配置更改为 clang,这会影响这个吗?

我试过了

export CC=gcc
export CXX=gcc
export CXXFLAGS=-mmacosx-version-min=10.8

或者

export CC=clang
export CXX=clang
export CXXFLAGS=-mmacosx-version-min=10.8

并重新安装couchnode,但没有奏效

欢迎您的评论

4

1 回答 1

0

有相关错误:“错误:dlopen([...]/app/node_modules/couchbase/prebuilt/win/x64/couchbase_impl.node, 1): 找不到合适的图像”

我能够在 OS X 10.9.5 和 xcode 6.0.1 上解决这个问题

安装 libcouchbase 的新副本:

$ brew install libcouchbase

这会将 libcouchbase 安装到/usr/local/Cellar/libcouchbase/2.4.1(或任何当前版本)。接下来通过 npm 安装 Node-SDK

$ npm install --couchbase-root=/usr/local/Cellar/libcouchbase/2.4.1 couchbase

看起来你需要在 OS X 上安装时声明 --couchbase-root=

于 2014-10-05T09:20:37.987 回答