Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

phantomjs.path is null #533

Open
igorissen opened this issue Apr 14, 2016 · 6 comments
Open

phantomjs.path is null #533

igorissen opened this issue Apr 14, 2016 · 6 comments

Comments

@igorissen
Copy link

Hi,

I have an issue that points to an issue with child_process.execFile(...) (Bad argument). So I have put som logs to show what is the path of phantomjs binary.

var phantomjs = require('phantomjs-prebuilt')
var binPath = phantomjs.path

console.log(phantomjs);
console.log(binPath);

The path is null.

// console.log(phantomjs);
(path=null, version=2.1.1)

// console.log(binPath);
null

I'm using node v5.10.1, phantomjs-prebuilt v2.1.7 and phantomjs binary v2.1.1

@JonForest
Copy link

JonForest commented Apr 16, 2016

I've just experienced the same issue on version phantomjs-prebuilt v2.1.5, and phantomjs binary v2.1.1.
Personally experienced in the html-pdf component, for which phantomjs-prebuilt is a dependency, but I can easily drop into the repl and see the path property is null.


Update: Just tried installing all of the versions from 2.1.3 to 2.1.7 into a temp folder, and all show the path property populated. Therefore there must be something about the installation process causing an issue.
Will continue to investigate


Eventually fixed. Individually everything was working fine. As a larger package.json it was failing silently due to running out of memory, presumably for the spawned phantomjs installation. This was on 1Gb Digital Ocean box.
In the end I create a 4Gb swap partition, nuked my node_modules, and went again. This time went again and everything is working out.
To check if this is your issue, take a look in:
node_modules/phantomjs-prebuilt/lib
You should have location.js, phantomjs.js and a phantom directory. If these are not all there, the install has failed at some point.

@igorissen
Copy link
Author

igorissen commented Apr 18, 2016

@JonForest You're right I have only phantomjs.js file in the lib folder. The strange thing is that I have enough memory on my PC (16GB, ~6GB free).


@JonForest In the directory node_modules/phantomjs-prebuilt/lib you can find a file named install.js. You need to run it in order to get all the files you specified location.js, phantom.js and phantom directory. So somehow the install.js script isn't called during installation.

$ cd node_modules/phantomjs-prebuilt
$ node install.js
Considering PhantomJS found at /usr/local/bin/phantomjs
Found PhantomJS at /usr/local/bin/phantomjs ...verifying
PhantomJS detected, but wrong version 2.1.1 @ /usr/local/bin/phantomjs.
Downloading https://github.com/Medium/phantomjs/releases/download/v1.9.19/phantomjs-1.9.8-macosx.zip
Saving to /var/folders/v0/j_5qj6h96jd8x_f7k0dncw9h0000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip
Receiving...
  [========================================] 100%
Received 9187K total.
Extracting zip contents
Removing /Path/to/project/node_modules/phantomjs/lib/phantom
Copying extracted folder /var/folders/v0/j_5qj6h96jd8x_f7k0dncw9h0000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip-extract-1460965717750/phantomjs-1.9.8-macosx -> /Path/to/project/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /Path/to/project/node_modules/phantomjs/lib/phantom/bin/phantomjs

@JonForest
Copy link

@igorissen It really should be called. It's spawned as a separate process, so something is stopping that working. In my case it's memory, but I couldn't speculate usefully for you.
If you go to an empty directory and npm install phantomjs-prebuilt, are all the files present in that node_modules/phantomjs-prebuilt/lib?

@igorissen
Copy link
Author

@JonForest There is always one file phantomjs.js. I have used this command npm install phantomjs-prebuilt --loglevel silly 3 times and always the same result : only one file.

I have also noticed that there is no post-install, pre-install or install script.

...
npm sill decomposeActions fetch [email protected]
npm sill decomposeActions extract [email protected]
npm sill decomposeActions test [email protected]
npm sill decomposeActions preinstall [email protected]
npm sill decomposeActions build [email protected]
npm sill decomposeActions install [email protected]
npm sill decomposeActions postinstall [email protected]
npm sill decomposeActions finalize [email protected]
...
...
npm sill preinstall [email protected] /Users/fluxb0x/Projects/empty/node_modules/.staging/phantomjs-prebuilt-8cc766e0
npm info lifecycle [email protected]~preinstall: [email protected]
npm sill lifecycle [email protected]~preinstall: no script for preinstall, continuing
...
...
npm sill install [email protected] /Users/fluxb0x/Projects/empty/node_modules/.staging/phantomjs-prebuilt-8cc766e0
npm info lifecycle [email protected]~install: [email protected]
npm sill lifecycle [email protected]~install: no script for install, continuing
...
...
npm sill postinstall [email protected] /Users/fluxb0x/Projects/empty/node_modules/.staging/phantomjs-prebuilt-8cc766e0
npm info lifecycle [email protected]~postinstall: [email protected]
npm sill lifecycle [email protected]~postinstall: no script for postinstall, continuing
...

@dylanfoster
Copy link

I've run into this as well, installing phantomjs-prebuilt by itself seems to work, but subsequent fresh installs do not (i.e. when running `rm -rf node_modules && yarn install)

@bladerunner2020
Copy link

Have the same issue on Mac. Managed somehow to get it working in one project, but can't repeat it for another project. could anybody help with the step how to get it installed correctly?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants