8

I am trying to spin up a node.js server using the git aws.push method

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html

Similar to this solution, I'm trying to run 'bower install', though my solution is a bit different:

https://developer.ibm.com/answers/questions/16594/how-to-install-packages-on-nodejs/

my implementation:

"scripts": { "postinstall": "bower install -F" },

this works fine locally - npm install also runs bower install with no problems. when i deploy to aws, npm runs fine - i know that my server starts up fine because i can see messages from it in the logs, but none of the bower components are in place when i try to bring up the client.

i'm using node v0.10.26, and i am sure that i don't have bower installed globally on my local machine. i've tried this both with and without including bower in the dependencies section of my package.json.

any ideas? and thanks in advance.

package.json

{
  "name": "smf",
  "version": "0.1.0",
  "dependencies": {
    "aws-sdk": "~2.0.0-rc.14",
    "base64-js": "0.0.6",
    "bookshelf": "~0.6.10",
    "bower": "*",
    "change-case": "~2.1.1",
    "crypto-js": "~3.1.2-3",
    "geojson": "~0.1.5",
    "handlebars": "~2.0.0-alpha.2",
    "js-base64": "~2.1.5",
    "lodash": "~2.4.1",
    "mathjs": "~0.21.0",
    "minify": "~0.5.1",
    "moment": "~2.6.0",
    "newrelic": "~1.5.3",
    "node-cryptojs-aes": "~0.4.0",
    "node-highcharts": "0.0.2",
    "node-uuid": "~1.4.1",
    "passport": "~0.2.0",
    "passport-http": "~0.2.2",
    "passport-local": "~1.0.0",
    "password-hash": "~1.2.2",
    "pg": "~3.0.3",
    "restify": "~2.7.0",
    "should": "~3.3.1",
    "socket.io": "~0.9.16",
    "sqlite3": "~2.2.3",
    "util": "~0.10.3",
    "when": "~3.1.0"
  },
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-mocha-test": "~0.9.0",
    "mocha-phantomjs": "~3.3.1"
  },
  "scripts": {
    "postinstall": "bower install -F"
  },
  "engines": {
    "node": ">=0.6"
  }
}

LOG FILES

The entire log is too long, though I will paste it in multiple comments if you need. Below is the only section that mentions bower at all.

If I try to access the site, I can get access logs indicating that bower components are missing.

There doesn't appear to be any execution of bower install happening.


/var/log/directory-hooks-executor.log

[email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/node_modules/esprima [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/object-assign [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/uuid [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/object-assign [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain/node_modules/proto-list [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/ini [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/inherits [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/mkdirp [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/once [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/uid-number [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/semver-diff [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi [email protected] /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi/node_modules/ansi-regex [email protected] /tmp/deployment/application/node_modules/bower/node_modules/which

3
  • Can you try taking a snapshot of your logs as explained here: docs.aws.amazon.com/elasticbeanstalk/latest/dg/…? Also can you post the exact contents of package.json. The contents in your question currently show a comma at the end of the line "scripts": { "postinstall": "bower install -F" }, which may be causing problems. Just want to make sure if it is a typo. Commented Jul 17, 2014 at 1:45
  • i've added this info - but there really is no new info... Commented Jul 18, 2014 at 16:34
  • Same kind of problem here ... Commented Apr 9, 2015 at 13:53

3 Answers 3

6

bower is probably not installed globally (if it is, please tell me how to do that on elastic beanstalk :D ). You should instead point to the bin of bower in the node_modules folder (which is how we used to do it). We have turned away from that solution (consider it at a scale of 500 instances spinning up..) and are checking bower_components into the repo.

"scripts": {
  "postinstall": "node_modules/bower/bin/bower install -F"
},
Sign up to request clarification or add additional context in comments.

5 Comments

This doesn't run at all for me. Bower packages never show up and I get a 404 error.
Not yet. I'm still investigating it though. I tried running bower install as a container_commands script, but that errors out as well, because node isn't linked in the PATH environment variable. stackoverflow.com/a/19011144/859747 shows how to remedy that, but git needs to be linked as well. I'm not sure why Amazon wouldn't just run the postinstall. It should run when npm install runs.
I have also tested it with "postinstall": "node ./node_modules/bower/bin/bower install -F" but without success :(
and "postinstall": "/opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/bin/node ./node_modules/bower/bin/bower install -F" don't work too ... :(
"postinstall" is working fine for me...I have given another path in .bowerrc { "directory":"client/bower_components" } @BKH this might be helpful to you.Create .bowerrc file and add required directory path.
3

Adding a .config file to your .ebextensions dir to install bower components helps. Unfortunately, node and npm are not added to the path by default so you need to find the latest node instance and create a symlink. I'm really not a fan of installing the bower components as root but this'll work:

commands:
  01_get_sudo:
      command: echo Defaults:root \!requiretty >> /etc/sudoers
  02_node_path:
    command: "sudo ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /usr/bin/node"
  03_npm_path:
    command: "sudo ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /usr/bin/npm"

container_commands:
  01_bower_install:
    command: "sudo ./node_modules/bower/bin/bower install --allow-root"

Comments

0

Use $NODE_HOME, e.g.

container_commands:
  01_bower_install:
    command: "export PATH=$PATH; $NODE_HOME/bin/node ./node_modules/bower/bin/bower install --allow-root &>> /tmp/01_bower_install.log"

head -1 will not necessarily use the most recent version of node and npm.

For example...

$ ls -td /opt/elasticbeanstalk/node-install/node-* | head -1
/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64

whereas ls shows that v5.6.0 is actually the most recent:

$ ls -td /opt/elasticbeanstalk/node-install/node-*
/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64
/opt/elasticbeanstalk/node-install/node-v5.6.0-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.8.28-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.12.10-linux-x64

Even if it did, it's probably not what you want.

You can get around this by sorting, but you still probably want to use the same node version as the environment, which can be accessed via $NODE_HOME.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.