如何在 Openshift 上为 nodejs 安装 bcrypt?

How to install bcrypt for nodejs on Openshift?

使用 https://github.com/icflorescu/openshift-cartridge-nodejs 获取最新版本的节点,我 运行 npm install 得到以下错误:

npm ERR! Linux 2.6.32-573.12.1.el6.x86_64
npm ERR! argv "/var/lib/openshift/56c8cd172d527182dd0000e7/app-root/data/.nodejs/bin/node" "/var/lib/openshift/56c8cd172d527182dd0000e7/app-root/data/.nodejs/bin/npm" "install"
npm ERR! node v5.6.0
npm ERR! npm  v3.7.3
npm ERR! code ELIFECYCLE

npm ERR! bcrypt@0.8.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the bcrypt@0.8.5 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, 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 information on how to open an issue for this project with:
npm ERR!     npm bugs bcrypt
npm ERR! Or if that isn't available, 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!     /var/lib/openshift/56c8cd172d527182dd0000e7/app-root/runtime/repo/src/bookmap/npm-debug.log

我已经尝试将 node-gyp 显式列为 package.json 中的依赖项,这导致了同样的错误。这是我当前来自 package.json 的依赖项:

"dependencies": {
    "angular": "^1.4.8",
    "angular-datepicker": "~1.0.5",
    "angular-route": "^1.4.8",
    "angular-simple-logger": "^0.1.7",
    "angular-ui-bootstrap": "^0.14.3",
    "node-gyp": "",
    "bcrypt": "^0.8.5",
    "body-parser": "^1.14.1",
    "bootstrap": "^3.3.6",
    "bower": "^1.3.9",
    "express": "^4.13.3",
    "gulp": "^3.8.7",
    "gulp-connect": "^2.0.6",
    "jwt-simple": "^0.4.0",
    "leaflet": "^0.7.7",
    "lodash": "^3.10.1",
    "path": "^0.12.7",
    "pg": "^4.4.3",
    "ui-leaflet": "^1.0.0",
    "winston": "^2.1.1"
  }

node-gyp 使用 npm install node-gyp 安装得很好。

我建议使用 javascript 版本的 bcrypt,这样您就不必处理在 openshift 上构建它的问题。我们在 openshift 上使用 bcrypt-nodejs,它运行良好 https://www.npmjs.com/package/bcrypt-nodejs

您只需要将其置于 package.json 中的依赖项下即可。这是我们拥有的,但您可以查看并获取最新版本:

"bcrypt-nodejs": ">=0.0.3",

bcrypt-nodejs 在 openshift 中不工作。 使用这个 https://www.npmjs.com/package/bcryptjs