无法在Openshift上安装bower

时间:2014-05-29 16:01:19

标签: node.js openshift bower

我无法在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"
}

情况下:2

{
    "directory": "public libs"
}

此外,尝试运行以下命令[在$ HOME / app-root / runtime / repo]并尝试通过SSH shell安装bower

 npm cache clear
 npm cache clean

任何解决此问题的帮助都会很棒。

如果你想查看我的回购,你可以在这里找到它:https://github.com/prasunsultania/demoblog

3 个答案:

答案 0 :(得分:16)

以下是我如何使用node.js盒式磁带在OpenShift上使用bower

先决条件:

  • 通常您已全球安装了Bower。
  • 您推送到OpenShift的git仓库必须能够轻松配置为使用Bower,以便来自仓库根目录的bower install能够完成工作。

必要的步骤:

  1. 创建文件.openshift/action_hooks/deploy
  2. 在添加并将其提交到您的仓库之前,chmod +x .openshift/action_hooks/deploy使其成为可执行文件
  3. 将以下行添加到文件中:
  4. #!/usr/bin/env bash

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

答案 1 :(得分:6)

This建议采用以下方法:

  1. 将依赖关系"bower": "latest"添加到package.json
  2. 为postinstall添加脚本:

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

答案 2 :(得分:0)

好吧,每次你需要使用bower install,你可以在RHC工具中使用export HOME=$HOME/app-root/runtime/repo,然后使用文件夹&#39; ./ app-root / repo&#39 ;您可以使用bower install,如果bower命令不可用,请转到文件夹&#39; ./ nodejs&#39;做npm install bower

然后,按照RHC工具的顺序(这对我来说很完美):

  •     1 - rhc ssh proyect-name
  •     2 - cd nodejs
  •     3 - npm install bower
  •     4 - cd ..
  •     5 - export HOME=$HOME/app-root/runtime/repo
  •     6 - cd app-root/repo
  •     7 - bower install

完成了!祝你的项目好运