5

I'm trying to install an npm package globally on elastic beanstalk. This is what my config file looks like which I wrote based on this documentation.

container_commands:
  install_phantom:
    command: "npm install phantomjs -g"

And when I deploy to Elastic Beanstalk I get this error

Command failed on instance. Return code: 1 Output: Error occurred during build: Command install_phantom failed .

Simon Guest
  • 2,112
  • 1
  • 15
  • 21
Loourr
  • 4,995
  • 10
  • 44
  • 68
  • 1
    One thing I've found is that `npm` is not included in the path, but instead located at `/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/npm` – Loourr Aug 21 '14 at 17:57
  • Loourr - Did you have any luck with this? I've tried the above command, including specifying the exact path of npm, but the command always fails. – Simon Guest Apr 08 '15 at 16:02

2 Answers2

2

Based on the answer given here, have you tried:

container_commands:
  install_phantom:
    command: "export PATH=$PATH; npm install phantomjs -g"
Community
  • 1
  • 1
Francis Eytan Dortort
  • 1,407
  • 14
  • 20
  • This solution does not work (atleast right now) - trying this gives `npm: command not found`. For path, this works: https://gist.github.com/dduvnjak/3b21e247c9fcd409a12d – Vineet Apr 15 '19 at 02:54
0

The environment variable for the node installation is NODE_HOME, so you should do this, to run npm or node in a container command in your config files:

container_commands:
  install_phantom:
    command: bash -c "PATH=$PATH:$NODE_HOME/bin npm install phantomjs -g"
zakum1
  • 895
  • 6
  • 20
  • This solution does not work (atleast right now) - trying this gives `npm: command not found`. For path, this works: https://gist.github.com/dduvnjak/3b21e247c9fcd409a12d – Vineet Apr 15 '19 at 02:54