【问题标题】:Unable to install bower on Openshift无法在 Openshift 上安装凉亭
【发布时间】:2014-05-29 16:01:18
【问题描述】:

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

另外,尝试运行以下命令 [In $HOME/app-root/runtime/repo] 并尝试通过 SSH shell 进行 npm install bower

 npm cache clear
 npm cache clean

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

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

【问题讨论】:

  • 在我看来这是 bower 和 npm 引擎之间的版本兼容性问题。 npm 版本在 Openshift 上是 1.2.17,而 Heroku 和 Cloudcontrol 等其他平台在 1.4.x 上,凉亭安装就像一个魅力。 Openshift有没有办法升级npm引擎?

标签: node.js openshift bower


【解决方案1】:

以下是我在 OpenShift 上使用 node.js 插件使用 bower 的方法:

先决条件:

  • 通常您已全局安装 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

【讨论】:

  • 如果您在 Windows PC 上,则需要运行:git update-index --chmod=+x .openshift/action_hooks/deploy 而不是 chmod +x .openshift/action_hooks/deploy跨度>
【解决方案2】:

This 建议采用以下方法:

  1. 添加依赖"bower": "latest"package.json
  2. 为安装后添加脚本:

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

【讨论】:

    【解决方案3】:

    好吧,每次你需要使用bower install,你可以在RHC工具中使用export HOME=$HOME/app-root/runtime/repo,然后进入文件夹'./app-root/repo'你可以使用bower install,如果@ 987654326@ 命令不可用,转到文件夹“./nodejs”并执行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

    完毕!祝你的项目好运

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-22
      • 2017-03-18
      • 1970-01-01
      • 1970-01-01
      • 2017-12-08
      • 2013-07-03
      • 2014-02-09
      • 2013-05-23
      相关资源
      最近更新 更多