Install npm package globally on AWS Elastic Beanstalk

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 .