I'm having serious and intermittent problems getting phantomjs-prebuilt installed on Elastic Beanstalk using html-pdf. I've tried every solution I can find, but I'm not well versed in how to fix these things. I can't even figure out how to SSH into the instance, so please treat me like a complete novice. The error I'm currently getting is:
> node server.js
html-pdf: Failed to load PhantomJS module. { Error: Cannot find module 'phantomjs-prebuilt'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/app/current/node_modules/html-pdf/lib/pdf.js:7:19)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3) code: 'MODULE_NOT_FOUND' }
Server is running.
I've tried different install scripts in ebextensions, upping the instance (t2.micro-t2.small-t2.medium), some file called .npmrc and a bunch of other stuff.
How can I fix this problem permanently?
I can manage to get phantoms-prebuilt installed locally when just running npm install and the html-pdf lib HAS WORKED for several years, but then it just started to come back again, without me changing the package.json.
Any help much appreciated! Let me know what code you need to see!
EDIT: I've just set up CLI and SSH into the instance. There I ran the command:
sudo npm install -g phantomjs@2.1.1 --unsafe-perm
and then
sudo npm install -g phantomjs-prebuilt --unsafe-perm
but I'm still getting the exact same error message when I restart the application.