Question

PhantomJS on App Platform

Hi guys,

For some reason I get a PATH error at build. Is there a solution for it?

I tried to add is globally with: npm i -g phantomjs-prebuilt@^2.1.8

2025-01-30 14:55:49] 
[2025-01-30 14:55:49] ╭──────────── buildpack detection ───────────╼
[2025-01-30 14:55:49] │  › using Ubuntu 22.04 stack
[2025-01-30 14:55:50] │ Detected the following buildpacks suitable to build your app:
[2025-01-30 14:55:50] │ 
[2025-01-30 14:55:50] │    digitalocean/nodejs-appdetect  v0.0.5    
[2025-01-30 14:55:50] │    heroku/nodejs                  v0.260.4  (Node.js)
[2025-01-30 14:55:50] │    digitalocean/procfile          v0.0.5    (Procfile)
[2025-01-30 14:55:50] │    digitalocean/custom            v0.1.3    (Custom Build Command)
[2025-01-30 14:55:50] ╰─────────────────────────────────────────────╼
[2025-01-30 14:55:50] 
[2025-01-30 14:55:50] ╭──────────── app build ───────────╼
[2025-01-30 14:55:50] │        
[2025-01-30 14:55:50] │ -----> Creating runtime environment
[2025-01-30 14:55:50] │        
[2025-01-30 14:55:50] │        NPM_CONFIG_LOGLEVEL=error
[2025-01-30 14:55:50] │        USE_NPM_INSTALL=true
[2025-01-30 14:55:50] │        NODE_VERBOSE=false
[2025-01-30 14:55:50] │        NODE_ENV=
[2025-01-30 14:55:50] │        NODE_MODULES_CACHE=true
[2025-01-30 14:55:50] │        
[2025-01-30 14:55:50] │ -----> Installing binaries
[2025-01-30 14:55:50] │        engines.node (package.json):   unspecified
[2025-01-30 14:55:50] │        engines.npm (package.json):    unspecified (use default)
[2025-01-30 14:55:50] │        
[2025-01-30 14:55:51] │        Resolving node version 20.x...
[2025-01-30 14:55:51] │        Downloading and installing node 20.15.1...
[2025-01-30 14:55:53] │        Using default npm version: 10.7.0
[2025-01-30 14:55:54] │        
[2025-01-30 14:55:54] │ -----> Installing dependencies
[2025-01-30 14:55:54] │        Installing node modules (package.json + package-lock)
[2025-01-30 14:57:33] │        npm notice
[2025-01-30 14:57:33] │        npm notice New major version of npm available! 10.7.0 -> 11.1.0
[2025-01-30 14:57:33] │        npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.1.0
[2025-01-30 14:57:33] │        npm notice To update run: npm install -g npm@11.1.0
[2025-01-30 14:57:33] │        npm notice
[2025-01-30 14:57:33] │        npm error code 1
[2025-01-30 14:57:33] │        npm error path /workspace/node_modules/phantomjs
[2025-01-30 14:57:33] │        npm error command failed
[2025-01-30 14:57:33] │        npm error command sh -c node install.js
[2025-01-30 14:57:33] │        npm error PhantomJS not found on PATH
[2025-01-30 14:57:33] │        npm error Phantom installation failed TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
[2025-01-30 14:57:33] │        npm error     at Object.join (node:path:1175:7)
[2025-01-30 14:57:33] │        npm error     at findSuitableTempDirectory (/workspace/node_modules/phantomjs/install.js:127:30)
[2025-01-30 14:57:33] │        npm error     at /workspace/node_modules/phantomjs/install.js:476:19
[2025-01-30 14:57:33] │        npm error     at nextTickCallback (/workspace/node_modules/kew/kew.js:47:28)
[2025-01-30 14:57:33] │        npm error     at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
[2025-01-30 14:57:33] │        npm error   code: 'ERR_INVALID_ARG_TYPE'
[2025-01-30 14:57:33] │        npm error } TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
[2025-01-30 14:57:33] │        npm error     at Object.join (node:path:1175:7)
[2025-01-30 14:57:33] │        npm error     at findSuitableTempDirectory (/workspace/node_modules/phantomjs/install.js:127:30)
[2025-01-30 14:57:33] │        npm error     at /workspace/node_modules/phantomjs/install.js:476:19
[2025-01-30 14:57:33] │        npm error     at nextTickCallback (/workspace/node_modules/kew/kew.js:47:28)
[2025-01-30 14:57:33] │        npm error     at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │        npm error A complete log of this run can be found in: /tmp/npmcache.taC4h/_logs/2025-01-30T14_55_54_632Z-debug-0.log
[2025-01-30 14:57:33] │ 
[2025-01-30 14:57:33] │ -----> Build failed
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │        We're sorry this build is failing! You can troubleshoot common issues here:
[2025-01-30 14:57:33] │        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │        Some possible problems:
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │        - Node version not specified in package.json
[2025-01-30 14:57:33] │          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │        Love,
[2025-01-30 14:57:33] │        Heroku
[2025-01-30 14:57:33] │        
[2025-01-30 14:57:33] │ ERROR: failed to build: exit status 1
[2025-01-30 14:57:34] │ 
[2025-01-30 14:57:34] │ 
[2025-01-30 14:57:34] │  ✘ build failed
[]


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 2, 2025

Hey!

The error suggests that the build process isn’t recognizing the installed PhantomJS.

Instead of installing it globally, add it as a dependency:

npm install phantomjs-prebuilt --save

And then reference the bin directory in the node_modules, eg:

"scripts": {
  "postinstall": "export PATH=$PATH:./node_modules/.bin"
}

If the above does not work, you could also try to modify your App Platform build command to explicitly install PhantomJS:

"build_command": "npm install && npm rebuild phantomjs-prebuilt"

If the issue persists, do you by any chance have your repository publicly available? I could try deploying it on my end to further investigate it.

- Bobby

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.