I JUST managed to figure a solution out to a similar problem in my environment. Running node 10.15. Perhaps you've already resolved this-- if so, congrats! And full disclaimer, I'm not an expert with Elasticbeanstalk configuration, but wanted to share a potential solution.
Try adding a yaml configuration file in /.ebextension
with the below contents:
commands:
99-installphantom:
env:
PATH: /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/bin/
command: npm install -g phantomjs-prebuilt --unsafe-perm
This forces the install of phantomjs globally, and the --unsafe-perm
flag runs the script with root privileges.
Got the hint by using the last comment in this issue, which then caused a 'permission denied error'-- hence unsafe-perm.
For reference, I also have the below Elasticbeanstalk settings, which apparently just aren't quite enough to npm install everything...:
/.ebextensions/00_change_npm_permissions.config
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
chown -R nodejs:nodejs /tmp/.npm
.npmrc
in the same directory as package.json
# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm
unsafe-perm=true