meteorhacks / npm

Complete NPM integration for Meteor
http://meteorhacks.com/complete-npm-integration-for-meteor.html
MIT License
508 stars 43 forks source link

Compatibility issue with Packages based Architecture (with PhantomJS) #126

Open anothermohit opened 8 years ago

anothermohit commented 8 years ago

Hi,

I am trying to use Phantomjs. It works perfectly fine if I install it directly in my Meteor directory following these steps - http://stackoverflow.com/a/28125219/4382567

But I am not able to get it to work when keeping this code in a separate local package.

Here is what I am doing: I have set the dependency of my package on meteorhacks:npm (and tried npm-container too) and keeping the packages.json file in the root path of my package.

The error I am getting: ReferenceError: require is not defined

Could you please tell me how to resolve this?

anothermohit commented 8 years ago

I have found a workaround myself but sadly it's not wrapping up the complete code in a package. Here is what worked for me, in case anybody else comes here looking

So, I added the package.json and private/phantomDriver.js in my ROOT meteor directory and put my Meteor method inside my local package. So, following this answer , you don't have to change any code, just reposition the files this way.

One weird thing happens when you don't put any js file in your ROOT directory, your assets (package.json and phantomDriver.js) sitting in the root becomes inaccessible. So, you have to create a blank .js file in the ROOT directory to resolve this meteor issue, if you don't have any other (like in the strict package architecture, but sadly it won't remain anymore now).