无法在Openshift上安装bower

7

我无法在 Openshift 上安装 bower。我一直收到类似以下的错误:

remote: npm ERR! Error: ENOENT, lstat '/var/lib/openshift/537xxxxcd/app-root/runtime/repo/node_modules/bower/node_modules/mout/array/intersection.js'[K
remote: npm ERR! If you need help, you may report this log at:[K
remote: npm ERR!     <http://github.com/isaacs/npm/issues>[K
remote: npm ERR! or email it to:[K
remote: npm ERR!     <npm-@googlegroups.com>[K

您可以通过此链接查看完整的部署日志: https://s3.amazonaws.com/archive.travis-ci.org/jobs/26291843/log.txt [来自travis]。

我尝试了几种方法: 1)使用或不使用.bowerrc文件

情况:1

{
    "directory": "~/app-root/runtime/repo/public/libs"
    "storage": {
            "cache": "~/app-root/runtime/repo/node_modules/bower/cache",
            "completion": "~/app-root/runtime/repo/node_modules/bower/completion",
            "git": "~/app-root/runtime/repo/node_modules/bower/git_template"
    },
    "interactive": "false",
    "tmp":"~/app-root/runtime/repo/node_modules/bower/tmp",
    "cwd":"~/app-root/runtime/repo"
}

case:2

{
    "directory": "public libs"
}

此外,我尝试在$HOME/app-root/runtime/repo目录下运行以下命令,并尝试通过SSH shell安装npm install bower。
 npm cache clear
 npm cache clean

任何帮助解决这个问题都会很好。
如果您想查看我的存储库,可以在这里找到它:https://github.com/prasunsultania/demoblog

我觉得这是bower和npm引擎之间版本兼容性问题。在Openshift上,npm版本是1.2.17,而Heroku和Cloudcontrol等其他平台的版本是1.4.x,因此bower install可以正常工作。在Openshift上有没有升级npm引擎的方法? - prasun
3个回答

16

以下是我如何在OpenShift使用node.js插件以及:

前提条件:

  • 通常情况下,您已经全局安装了Bower。
  • 您推送到OpenShift的git仓库必须已经配置好使用Bower,这样从仓库的根目录运行bower install就可以完成工作。

必要步骤:

  1. 创建文件.openshift/action_hooks/deploy
  2. 在将其添加和提交到您的仓库之前,执行chmod +x .openshift/action_hooks/deploy使其可执行
  3. 将以下行添加到文件中:

#!/usr/bin/env bash

HOME=$HOME/app-root/runtime
cd ~/repo
npm install bower
./node_modules/.bin/bower install
  1. 将文件添加并提交到您的git存储库
  2. 将您的git存储库推送到OpenShift

3
如果您正在使用Windows PC,您需要运行以下命令:git update-index --chmod=+x .openshift/action_hooks/deploy,而不是 chmod +x .openshift/action_hooks/deploy。 - Vasil Trifonov

6

表明以下方案:

  1. Add dependency "bower": "latest" to package.json
  2. Add script for postinstall:

    "scripts": {  
        ... 
        "postinstall": "HOME=$OPENSHIFT_REPO_DIR bower install || bower install"  
    },
    

0

好的,每次需要使用bower install时,您可以在RHC工具中使用export HOME=$HOME/app-root/runtime/repo,然后进入文件夹'./app-root/repo',您可以使用bower install,如果bower命令不可用,请转到文件夹'./nodejs'并执行npm install bower

然后,按照 RHC 工具(对我来说非常完美)的顺序进行:
  • 1 - rhc ssh项目名称
  • 2 - cd nodejs
  • 3 - npm安装弓
  • 4 - cd..
  • 5 - 输出HOME = $ HOME / app-root / runtime / repo
  • 6 - cd app-root / repo
  • 7 - 弓安装
完成!祝你的项目好运。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接