OpenShift:ImportError:在NodeJs / Mongo盒上没有名为gyp的模块:

时间:2015-07-10 14:39:36

标签: node.js mongodb openshift node-gyp openshift-cartridge

我安装了 NodeJS MongoDB 磁带的 OpenShift 设备。我添加了 KeystoneJS ,当我尝试推送更新的代码时,由于缺少gyp模块,构建失败。完整错误堆栈如下。

是否还有其他人遇到缺少节点/ mongo盒式gyp模块的问题?

谢谢! Nirav

remote: Traceback (most recent call last):
remote: File "/opt/rh/v8314/root/usr/bin/gyp", line 15, in 
remote: import gyp
remote: ImportError: No module named gyp
remote: gyp ERR! configure error
remote: gyp ERR! stack Error: gyp failed with exit code: 1
remote: gyp ERR! stack at ChildProcess.onCpExit (/opt/rh/nodejs010/root/usr/lib/node_modules/node-gyp/lib/configure.js:343:16)
remote: gyp ERR! stack at ChildProcess.emit (events.js:98:17)
remote: gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
remote: gyp ERR! System Linux 2.6.32-504.16.2.el6.x86_64
remote: gyp ERR! command "node" "/opt/rh/nodejs010/root/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
remote: gyp ERR! cwd /var/lib/openshift/559fa9944382ec4cf1000106/app-root/runtime/repo/node_modules/keystone/node_modules/keystone-utils/node_modules/limax/node_modules/cld
remote: gyp ERR! node -v v0.10.35
remote: gyp ERR! node-gyp -v v1.0.2
remote: gyp ERR! not ok
remote:
remote: npm info cld@2.4.3 Failed to exec install script
remote: npm ERR! EEXIST, open '/var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock'
remote: File exists: /var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock
remote: Move it away, and try again.
remote: npm ERR! System Linux 2.6.32-504.16.2.el6.x86_64
remote: npm ERR! command "node" "/opt/rh/nodejs010/root/usr/bin/npm" "install" "-d"
remote: npm ERR! cwd /var/lib/openshift/559fa9944382ec4cf1000106/app-root/runtime/repo
remote: npm ERR! node -v v0.10.35
remote: npm ERR! npm -v 1.4.28
remote: npm ERR! path /var/lib/openshift/559fa9944382ec4cf1000106/.npm/0fe9cfe4-6-npm-mime-db-1-14-0-package-tgz.lock
remote: npm ERR! code EEXIST
remote: npm ERR! errno 47

1 个答案:

答案 0 :(得分:1)

这个错误也突然发生在我身上,即使之前有过这样的错误。由于某种原因,Python npm模块在​​盒式磁带中不可用或无法找到。虽然我不知道发生了什么变化,但我通过升级用于部署的.openshift/action_hooks/pre_build安装找到了解决方法。

为此,我添加了两个动作挂钩:

  1. #!/bin/sh # We need to move the package.json file out of the way in pre_build, so # that the OpenShift git post-receive hook doesn't try and use the old # npm version to install the dependencies. mv ${OPENSHIFT_REPO_DIR}/package.json \ ${OPENSHIFT_TMP_DIR}/${OPENSHIFT_APP_UUID}_package.json

    .openshift/action_hooks/build
  2. #!/bin/sh # we moved the package.json file out of the way in pre_build, # so that the OpenShift git post-receive hook doesn't try and use the # old npm version to install the dependencies. Move it back in. mv ${OPENSHIFT_TMP_DIR}/${OPENSHIFT_APP_UUID}_package.json \ ${OPENSHIFT_REPO_DIR}/package.json cd ${OPENSHIFT_REPO_DIR} # We need an updated npm available for node-gyp to work reliable npm install npm # Now install the packages with the new npm version ./node_modules/.bin/npm install

    $PYTHONPATH
  3. 以这种方式使用替代npm安装的想法取自https://github.com/ryanj/nodejs-custom-version-openshift/tree/master/.openshift/action_hooks

    我也尝试过使用环境变量并设置<div> <p class:"test">text1</p> <img src="" class="image"> </div> <div> <p class:"test">text2</p> <img src="" class="image"> </div> ,但在构建期间没有成功使用该方法(尽管我让它在手动安装上工作)。