Thursday 3 November 2016

Meteor + PhantomJS fix (when npm install on Phusion Passenger server)

When deploying my Meteor app on Phusion Passenger installed on Ubuntu I encountered an issue when installing dependencies for production (as described in PP's tutorial Step 2.3)

Initially I thought it's an issue with node-pre-gyp but after error log inspection it turned out it's PhanomJS causing the problem:

Phantom installation failed { [Error: EACCES: permission denied, open '/var/www/myapp/bundle/programs/server/npm/node_modules/meteor/momentjs_moment/node_modules/phantomjs-prebuilt/lib/location.js']

To fix it simply change permissions:

sudo chmod 0777 /var/www/myapp/bundle/programs/server/npm/node_modules/meteor/momentjs_moment/node_modules/phantomjs-prebuilt/lib/location.js

Now npm install --production should work fine