sheebz / phantom-proxy

a lightweight proxy that lets you to drive phantomjs from node.
MIT License
137 stars 34 forks source link

Unknown module ./server for require() #8

Closed toranb closed 11 years ago

toranb commented 11 years ago

Using node 0.8.9

I recently decided to leave the original phantom npm project as it's not maintained and yours appears to be the most active. In doing so I've run into an error that says

Unknown module ./server for require()

When I try to spin up an express web server, then the proxy to scrape the page being hosted. I can hit the express web app while my npm code is running so it doesn't appear to be express related (that I've found yet).

Just curious if you have had this issue or seen anything like it in the past ?

Here is my basic usage of the phantom-proxy code to scrape it (note I see the first print but not the 2nd)

var app = require('./app.js'); // the file I require above exports like so // exports.webserver = server; app.webserver.listen(8091);

console.log("first"); var phantomProxy = require('phantom-proxy').create(function(proxy){ console.log("here?"); var page = proxy.page
, phantom = proxy.phantom;

    page.open("http://localhost:8091", function() {
        page.waitForSelector('body', function(){

        });
    });
});
sheebz commented 11 years ago

Hi, what OS are you using?

sheebz commented 11 years ago

might be a problem with the ./ paths in server/index, does it work if you change ./ server to absolute path in server/index.js?

toranb commented 11 years ago

Found this was a problem on both OSX 10.8.2 and Ubuntu 12.10. -so about the path suggestion ... this is something that would need to change in the underlying node.js app (correct?). Where would I change this if the code for that node app looks something like the below?

https://gist.github.com/4192196

capaj commented 11 years ago

I have the exact same issue on Ubuntu 12.10. I tried supplying the absolute path and it did change the warning to: "Unknown module /home/capaj/WebstormProjects/dem2cz_node_app/node_modules/phantom-proxy/lib/server/server.js for require()" so it is the problematic spot, but changing it to absolute path does not fix it. Does anyone has proper solution?

sheebz commented 11 years ago

This has been very difficult to track down. The fact that a full path works is puzzling. The node version, phantom version, stack trace, any other info would help.

capaj commented 11 years ago

I found the problem- I had phantom 1.4 on my system, because I got it from Ubuntu repository, where it was not updated for quite some time. Phantom-proxy works without any problem after I built myself phantomjs 1.8.1. I think this bug is obsolete and can be closed.

sheebz commented 11 years ago

@capaj thanks for the info! Was a little bit concerned about this one.