phantomjsazure-web-app-servicehtml-pdfnode-html-pdf

Can I use phantomJS on Azure app service for linux?


I'm getting a consistent error when trying to use the html-pdf package in my node application:

StatusError: Error: spawn /home/site/wwwroot/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT

As far as I can tell everything is installed correctly and the npm install works as expected. My suspicion is that there is some missing dependency in the built-in linux image, but I'm not sure how to confirm that.


Solution

  • According to the information comes from the Download PhantomJS page, there is two note for Linux Distributions as below.

    Note: For this static build, the binary is self-contained. There is no requirement to install Qt, WebKit, or any other libraries. It however still relies on Fontconfig (the package fontconfig or libfontconfig, depending on the distribution). The system must have GLIBCXX_3.4.9 and GLIBC_2.7.

    So the native package fontconfig or libfontconfig must have been installed in docker image first.

    For Debian/Ubuntu system, you can add RUN apt install fontconfig in the docker file, and check the package installed whether be exists via the command dpkg -l|grep fontconfig.

    For Fedora/CentOS system, add RUN yum install -y fontconfig, and check the installed on via yum list installed|grep fontconfig.