marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.55k stars 544 forks source link

docker node:16-alpine3.15 - not working #662

Open AviramTMO opened 2 years ago

AviramTMO commented 2 years ago

Here is how I install it:

# Download+Install PhantomJS, as the npm package 'phantomjs-prebuilt' won't work on alpine!
# See https://github.com/dustinblackman/phantomized
RUN set -ex \
    && apk add --no-cache --virtual .build-deps ca-certificates openssl \
    && wget -qO- "https://github.com/dustinblackman/phantomized/releases/download/2.1.1/dockerized-phantomjs.tar.gz" | tar xz -C / \
    && npm install -g phantomjs \
    && apk del .build-deps

After upgrading to node 16 from 12 I'm getting this error:


  + tar xz -C /
  + npm install -g phantomjs
  npm WARN deprecated cryptiles@2.0.5: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
  npm WARN deprecated phantomjs@2.1.7: Package renamed to phantomjs-prebuilt. Please update 'phantomjs' package references to 'phantomjs-prebuilt'
  npm WARN deprecated sntp@1.0.9: This module moved to @hapi/sntp. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
  npm WARN deprecated boom@2.10.1: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
  npm WARN deprecated hoek@2.16.3: This version has been deprecated in accordance with the hapi support policy (hapi.im/support). Please upgrade to the latest version to get the best features, bug fixes, and security patches. If you are unable to upgrade at this time, paid support is available for older versions (hapi.im/commercial).
  npm WARN deprecated har-validator@2.0.6: this library is no longer supported
  npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
  npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
  npm WARN deprecated mkdirp@0.5.0: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
  npm WARN deprecated request@2.67.0: request has been deprecated, see https://github.com/request/request/issues/3142
  npm WARN deprecated hawk@3.1.3: This module moved to @hapi/hawk. Please make sure to switch over as this distribution is no longer supported and may contain bugs and critical security issues.
  npm ERR! code 1
  npm ERR! path /usr/local/lib/node_modules/phantomjs
  npm ERR! command failed
  npm ERR! command sh -c node install.js
  npm ERR! Considering PhantomJS found at /usr/local/bin/phantomjs
  npm ERR! Looks like an `npm install -g`
  npm ERR! Error checking path, continuing Error: Cannot find module '/usr/local/lib/node_modules/phantomjs/lib/location'
  npm ERR! Require stack:
  npm ERR! - /usr/local/lib/node_modules/phantomjs/install.js
  npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
  npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
  npm ERR!     at Module.require (node:internal/modules/cjs/loader:1005:19)
  npm ERR!     at require (node:internal/modules/cjs/helpers:102:18)
  npm ERR!     at getLocationInLibModuleIfMatching (/usr/local/lib/node_modules/phantomjs/install.js:332:19)
  npm ERR!     at Promise._successFn (/usr/local/lib/node_modules/phantomjs/install.js:389:28)
  npm ERR!     at nextTickCallback (/usr/local/lib/node_modules/phantomjs/node_modules/kew/kew.js:47:28)
  npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  npm ERR!   code: 'MODULE_NOT_FOUND',
  npm ERR!   requireStack: [ '/usr/local/lib/node_modules/phantomjs/install.js' ]
  npm ERR! }
  npm ERR! Phantom installation failed TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
  npm ERR!     at new NodeError (node:internal/errors:371:5)
  npm ERR!     at validateString (node:internal/validators:120:11)
  npm ERR!     at Object.join (node:path:1172:7)
  npm ERR!     at findSuitableTempDirectory (/usr/local/lib/node_modules/phantomjs/install.js:127:30)
  npm ERR!     at /usr/local/lib/node_modules/phantomjs/install.js:476:19
  npm ERR!     at nextTickCallback (/usr/local/lib/node_modules/phantomjs/node_modules/kew/kew.js:47:28)
  npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  npm ERR!   code: 'ERR_INVALID_ARG_TYPE'
  npm ERR! } TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
  npm ERR!     at new NodeError (node:internal/errors:371:5)
  npm ERR!     at validateString (node:internal/validators:120:11)
  npm ERR!     at Object.join (node:path:1172:7)
  npm ERR!     at findSuitableTempDirectory (/usr/local/lib/node_modules/phantomjs/install.js:127:30)
  npm ERR!     at /usr/local/lib/node_modules/phantomjs/install.js:476:19
  npm ERR!     at nextTickCallback (/usr/local/lib/node_modules/phantomjs/node_modules/kew/kew.js:47:28)
  npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:78:11)```
e-tip commented 2 years ago

There's another version of dockerized-phantomjs https://github.com/dustinblackman/phantomized/releases/download/2.1.1a/dockerized-phantomjs.tar.gz Which i actually use on my k8s env with node 16.13