Unable to install bower on Openshift

点点圈 提交于 2019-12-03 07:16:21

Here is how I made use of bower on OpenShift using the node.js cartridge:

Prerequisites:

  • Usually you have installed Bower globally.
  • The git repo which you push to OpenShift must be readily configured for using Bower so that bower install from the root of the repo will do the job.

Necessary steps:

  1. Create the file .openshift/action_hooks/deploy
  2. Do chmod +x .openshift/action_hooks/deploy to make it executable BEFORE you add and commit it to your repo
  3. Add the following lines to the file:

#!/usr/bin/env bash

HOME=$HOME/app-root/runtime
cd ~/repo
npm install bower
./node_modules/.bin/bower install
  1. Add and commit the file to your git repo
  2. Push your git repo to OpenShift

This suggests the following approach:

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

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

well, for each time you need to use bower install, you can use export HOME=$HOME/app-root/runtime/repo in the RHC tool, and then into the folder './app-root/repo' you can use the bower install, if bower command is not available, go to folder './nodejs' and do npm install bower.

Then, in order with RHC tool (this worked perfect to me):

  • 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

done! good luck with your projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!