7

I've got a PHP application that uses gulp to build the production files, I'm using elasticbeanstalk to deploy my app to and AWS EC2 instance and I want to install node and npm to run gulp during the deploy, my current configuration is:

01-installPackages.config inside .ebextenstions folder

commands:
  01updateComposer:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update
  02installNode:
    command:
      # run this command from /tmp directory
      cwd: /tmp
      # don't run the command if node is already installed (file /usr/bin/node exists)
      test: '[ ! -f /usr/bin/node ] && echo "node not installed"'
      # install from epel repository
      # flag -y for no-interaction installation
      command: 'sudo yum install -y nodejs --enablerepo=epel'

the node commands fails but if I ssh in and i run that command node is installed

any idea of what's wrong with my configuration?

Thanks!

2
  • Hey @matteo, did you have a solution? You can share? Commented May 3, 2017 at 15:52
  • unfortunately no Commented May 5, 2017 at 7:42

2 Answers 2

2

The current answer for this is the following:

commands:
  01enable_epel:
    command: sudo amazon-linux-extras install epel
  02npm_install:
    command: sudo yum -y --enablerepo=epel install nodejs npm

using the extras library documented in AWS docs

Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm on Amazon AMI Linux 2
0

You should be able to use the environment configuration options for this rather than writing a bash file yourself. You can use the packages key to download and install prepackaged applications and components.

This will allow you do something like this:

packages: 
  yum:
    nodejs: [] 
    npm: []

And the packages you require will be installed.

Note: This has been deprecated in Amazon Linux 2.

3 Comments

Thanks for your answer, I originally tried that but I had some problems with sudo and the execution was even slower than creating a file
This threw errors telling me those packages weren't available via yum.
@JamesParker Same response here. Any Solution?

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.