Solvedphantomjs Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js'

Server configuration :

  • AWS Elastic Beanstalk with 64bit Amazon Linux & Docker 1.11.2
  • Node : 4.0

Docker file:

FROM ubuntu:14.04
FROM node:argon

# Create app directory
RUN mkdir -p /myapp
WORKDIR  /myapp

# Install app dependencies
COPY package.json /myapp
RUN npm install

Error log

  [0m[91mnpm [0m[91mERR! Linux 4.4.35-33.55.amzn1.x86_64
  [0m[91mnpm [0m[91mERR! [0m[91margv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
  [0m[91mnpm [0m[91mERR! [0m[91mnode v4.7.0
  [0m[91mnpm [0m[91mERR! [0m[91mnpm  v2.15.11
  [0m[91mnpm [0m[91mERR! [0m[91mcode ELIFECYCLE
  [0m[91m
  npm[0m[91m ERR![0m[91m phantomjs-prebuilt@2.1.14 install: `node install.js`
  npm[0m[91m ERR![0m[91m Exit status 1
  npm[0m[91m ERR![0m[91m 
  npm[0m[91m ERR![0m[91m Failed at the phantomjs-prebuilt@2.1.14 install script 'node install.js'.
  npm[0m[91m ERR![0m[91m This is most likely a problem with the phantomjs-prebuilt package,
  npm[0m[91m ERR![0m[91m not with npm itself.
  npm[0m[91m ERR![0m[91m Tell the author that this fails on your system:
  npm[0m[91m ERR![0m[91m     node install.js
  npm[0m[91m ERR![0m[91m You can get information on how to open an issue for this project with:
  npm[0m[91m ERR![0m[91m     npm bugs phantomjs-prebuilt
  npm[0m[91m ERR![0m[91m Or if that isn't available, you can get their info via:
  npm[0m[91m ERR![0m[91m 
  npm[0m[91m ERR![0m[91m     npm owner ls phantomjs-prebuilt
  npm[0m[91m ERR![0m[91m There is likely additional logging output above.
  [0m[91mnpm [0m[91minfo [0m[91mpreuninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91muninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91mpostuninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91mpreuninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91muninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91mpostuninstall phantomjs-prebuilt@2.1.14
  [0m[91mnpm [0m[91minfo [0m[91mpreuninstall phantom@2.1.21
  [0m[91mnpm [0m[91minfo [0m[91muninstall phantom@2.1.21
  [0m[91mnpm [0m[91minfo [0m[91mpostuninstall phantom@2.1.21
  [0m[91m
  [0m[91mnpm [0m[91mERR! Please include the following file with any support request:
  [0m[91mnpm [0m[91mERR!     /myapp/npm-debug.log
  [0mThe command '/bin/sh -c npm install' returned a non-zero code: 1
  Failed to build Docker image aws_beanstalk/staging-app:  with any support request:
  [0m[91mnpm [0m[91mERR!     /myapp/npm-debug.log
  [0mThe command '/bin/sh -c npm install' returned a non-zero code: 1. Check snapshot logs for details. (Executor::NonZeroExitStatus)
25 Answers

✔️Accepted Answer

Running apt-get -qq update && apt-get -qq -y install bzip2 before installing phantomjs is a possible workaround. It worked for me.

Other Answers:

I just got it working by installing phantomjs before the rest of the packages.

COPY package.json .
RUN npm install phantomjs-prebuilt 
RUN npm install

Can confirm that @joswhite's fix worked for me as well; the container I was using for my DeployBot builds (not the stock container, FWIW) apparently didn't have bzip2, so I added the following to my build commands:

apt-get install -y bzip2

here's my solution:
download https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
then put it into C:\Users\Administrator\AppData\Local\Temp\phantomjs
then npm install phantomjs-prebuilt
finnally npm i,
that fix mine on windows

The resolution is the same for CentOS -- Installing bzip2 solved the issue.