suchen

Heim  >  Fragen und Antworten  >  Hauptteil

node.js - node 报错: bcrypt 无法 install

使用中遇到以下错误:

➜ Hime git:(master) npm install

> bcrypt@0.8.3 install /Users/yanhan/Hime/node_modules/bcrypt
> node-gyp rebuild

然后启动 mongodb:

mongod --dbpath /usr/local/var/mongodb/

2015-06-11T11:58:15.079+0800 I JOURNAL  [initandlisten] journal dir=/usr/local/var/mongodb/journal
2015-06-11T11:58:15.080+0800 I JOURNAL  [initandlisten] recover : no journal files present, no recovery needed
2015-06-11T11:58:15.095+0800 I JOURNAL  [durability] Durability thread started
...

最后想要使用 node bin/run 报错:

➜ Hime git:(master) node bin/www
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
/Users/yanhan/Hime/node_modules/mongodb/lib/server.js:274
      process.nextTick(function() { throw err; })
                                          ^
Error: Could not locate the bindings file. Tried:
 → /Users/yanhan/Hime/node_modules/bcrypt/build/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/build/Debug/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/build/Release/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/out/Debug/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/Debug/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/out/Release/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/Release/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/build/default/bcrypt_lib.node
 → /Users/yanhan/Hime/node_modules/bcrypt/compiled/0.12.4/darwin/x64/bcrypt_lib.node
    at bindings (/Users/yanhan/Hime/node_modules/bcrypt/node_modules/bindings/bindings.js:88:9)
    at Object.<anonymous> (/Users/yanhan/Hime/node_modules/bcrypt/bcrypt.js:3:35)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/Users/yanhan/Hime/common/util.js:1:76)
    at Module._compile (module.js:460:26)

搜索了一下之后参考了stack overflow 上这个答案

http://stackoverflow.com/questions/21656420/failed-to-load-c-bson-exte...

但是还是不行。几个方法都试过了(包括改 index.js 里面的 bson 路径)

目前不确定到底是 bson 问题?还是 mogondb?还是?

谢谢帮助。

=================================

用 cnpm 重试,报错如下:

➜ Hime git:(master) rimraf node_modules/
➜ Hime git:(master) cnpm cache clean
➜ Hime git:(master) cnpm install

> bcrypt@0.8.3 install /Users/yanhan/Hime/node_modules/bcrypt
> node-gyp rebuild

gyp: /Users/yanhan/.node-gyp/0.12.4/common.gypi not found (cwd: /Users/yanhan/Hime/node_modules/bcrypt) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/cnpm/node_modules/pangyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.3.0
gyp ERR! command "node" "/usr/local/lib/node_modules/cnpm/node_modules/pangyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/yanhan/Hime/node_modules/bcrypt
gyp ERR! node -v v0.12.4
gyp ERR! pangyp -v v2.1.0
gyp ERR! not ok

> kerberos@0.0.12 install /Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

npm WARN installMany nopt was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany npmlog was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany request was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany semver was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany tar was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany tar-pack was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany mkdirp was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany rc was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
npm WARN installMany rimraf was bundled with node-pre-gyp@0.6.4, but bundled package wasn't found in unpacked tree
/
> bson-ext@0.1.7 install /Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext
> (node-pre-gyp install --fallback-to-build) || (node-gyp rebuild 2> builderror.log) || (exit 0)

gyp: /Users/yanhan/.node-gyp/0.12.4/common.gypi not found (cwd: /Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext) while reading includes of binding.gyp while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/cnpm/node_modules/pangyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.3.0
gyp ERR! command "/usr/local/Cellar/node/0.12.4/bin/node" "/usr/local/lib/node_modules/cnpm/node_modules/pangyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release/bson.node" "--module_name=bson" "--module_path=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release"
gyp ERR! cwd /Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext
gyp ERR! node -v v0.12.4
gyp ERR! pangyp -v v2.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/0.12.4/bin/node /usr/local/lib/node_modules/cnpm/node_modules/pangyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release/bson.node --module_name=bson --module_path=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
node-pre-gyp ERR! stack     at maybeClose (child_process.js:1015:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
node-pre-gyp ERR! System Darwin 14.3.0
node-pre-gyp ERR! command "node" "/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext
node-pre-gyp ERR! node -v v0.12.4
node-pre-gyp ERR! node-pre-gyp -v v0.6.4
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/0.12.4/bin/node /usr/local/lib/node_modules/cnpm/node_modules/pangyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release/bson.node --module_name=bson --module_path=/Users/yanhan/Hime/node_modules/mongodb/node_modules/mongodb-core/node_modules/bson/node_modules/bson-ext/build/Release' (1)
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/lib/node_modules/cnpm/node_modules/.bin/npm" "--userconfig=/Users/yanhan/.cnpmrc" "--disturl=https://npm.taobao.org/mirrors/node" "--cache=/Users/yanhan/.cnpm" "--registry=https://registry.npm.taobao.org" "--node-gyp=/usr/local/lib/node_modules/cnpm/node_modules/pangyp/bin/node-gyp.js" "install"
npm ERR! node v0.12.4
npm ERR! npm  v2.7.6
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.3 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/yanhan/Hime/npm-debug.log
迷茫迷茫2784 Tage vor952

Antworte allen(2)Ich werde antworten

  • PHPz

    PHPz2017-04-17 11:51:12

    https://github.com/TooTallNate/node-gyp/issues/376
    http://stackoverflow.com/questions/17967546/common-gypi-not-found-erro...

    ~/.node_gyp,重装。

    Antwort
    0
  • 黄舟

    黄舟2017-04-17 11:51:12

    可以使用bcrypt-nodejs
    参考 http://www.cnblogs.com/aoping...

    Antwort
    0
  • StornierenAntwort