Skip to content

Fix phantomjs-prebuilt install for npm 5

username-removed-1144264 requested to merge patch-1 into master

This error happens when installing phantomjs-prebuilt on npm 5:

$ sudo npm install phantomjs-prebuilt@2.1.12 -g
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/phantomjs -> /usr/local/lib/node_modules/phantomjs-prebuilt/bin/phantomjs

> phantomjs-prebuilt@2.1.12 install /usr/local/lib/node_modules/phantomjs-prebuilt
> node install.js

Considering PhantomJS found at /usr/local/bin/phantomjs
Looks like an `npm install -g`
Could not link global install, skipping...
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
Saving to /tmp/phantomjs/phantomjs-2.1.1-macosx.zip
Receiving...
  [===================================-----] 87%
Received 16746K total.
Extracting zip contents
Removing /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1507141561491/phantomjs-2.1.1-macosx -> /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom
Phantom installation failed { Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1507141561491/phantomjs-2.1.1-macosx' -> '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom'
  errno: -13,
  code: 'EACCES',
  syscall: 'link',
  path: '/tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1507141561491/phantomjs-2.1.1-macosx',
  dest: '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom' } Error: EACCES: permission denied, link '/tmp/phantomjs/phantomjs-2.1.1-macosx.zip-extract-1507141561491/phantomjs-2.1.1-macosx' -> '/usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phantomjs-prebuilt@2.1.12 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the phantomjs-prebuilt@2.1.12 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/username/.npm/_logs/2017-10-04T18_26_02_917Z-debug.log

According to https://github.com/Medium/phantomjs/issues/707, this probably will not be fixed, so the workaround is:

sudo npm install phantomjs-prebuilt@2.1.12 -g --unsafe-perm

I was going to add an item to the troubleshooting doc since it sounds "unsafe", but:

  • I would expect almost no one installing GDK will have a problem doing this since the only other solution is to downgrade npm
  • Fixing the commands directly will save people a lot of wasted time
  • We're moving to headless Chrome soon anyway
  • Suspicious people will find this MR after blaming the commit for the explanation

Merge request reports

Loading