Installing Puppeteer+NPM/NODE
bateaumoteur
PROOP

2 months ago

Hello,

I'm currently migrating one of my applications from Heroku to Railpack.

I've managed to migrate all the functionality, but one obstacle remains. My Laravel application uses Browsershot, which itself uses Puppeteer to capture a web page. This is a crucial prerequisite for my app to function.

I suspect a Docker image will solve this problem, but I'd like to use your builder and Railpack in the same service as my app if possible.

This worked on Heroku, but I've been trying unsuccessfully here for a while now, so I need your help.

It must be something silly because it's showing that it can't find NPM or Node.json. However, they are indeed in my builder (see screenshot) and in my railpack.json file (see attached).

You can see the error below.

Could you help me? 🙂

Thank you.

`======== ERROR ======

Symfony\Component\Process\Exception\ProcessFailedException - Internal Server Error`

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin NODE_PATHnpm root -g "node" '/app/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/1486486319-0782528001774351125\/index.html","action":"pdf","options":{"args":["--disable-gpu","--disable-setuid-sandbox","--no-sandbox","--single-process","--disable-dev-shm-usage"],"viewport":{"width":800,"height":600},"displayHeaderFooter":true,"headerTemplate":"<p><\/p>","footerTemplate":"\n <div style=\"display:block; bottom: 25px; text-align: center; margin: 0 auto;\">\n <img width=\"150px\"\n src=\"PDF DOC" failed.

Exit Code: 127(Command not found)

Working directory: /app/public

Output:

================

Error Output:

================

sh: 1: npm: not found

sh: 1: node: not found

PHP 8.5.4

Laravel 12.44.0

habbo.staging.oceanbilling.app

Solved$10 Bounty

Pinned Solution

ilyass012
FREE

2 months ago

i think i spotted your issue, your railpack.json is using keys that don't exist in the railpack schema like "build.providers" and "runtime.providers", those are not valid keys. the actual valid root-level keys are provider, packages, buildAptPackages, steps and deploy. because of this your nodejs provider is probably not being set up correctly at all, which is why node and npm are missing at runtime. try restructuring your config using the correct keys from the official docs here https://railpack.com/config/file and the node version config here https://railpack.com/languages/node

2 Replies

Railway
BOT

2 months ago

Railpack may include Node only in the build stage and not in the final runtime image when the primary detected language is PHP. To ensure Node and npm are available at runtime, try setting the RAILPACK_PACKAGES environment variable to node@20 in your service variables, which installs it via Mise into the deploy image. You can also refer to the Railpack config file docs for declaring packages that persist into the runtime. If that doesn't work, a Dockerfile would give you full control over what's included in the final image.


Status changed to Awaiting User Response Railway • about 2 months ago


Status changed to Awaiting Railway Response Railway • about 2 months ago


Status changed to Open Railway • about 2 months ago


ilyass012
FREE

2 months ago

i think i spotted your issue, your railpack.json is using keys that don't exist in the railpack schema like "build.providers" and "runtime.providers", those are not valid keys. the actual valid root-level keys are provider, packages, buildAptPackages, steps and deploy. because of this your nodejs provider is probably not being set up correctly at all, which is why node and npm are missing at runtime. try restructuring your config using the correct keys from the official docs here https://railpack.com/config/file and the node version config here https://railpack.com/languages/node


Status changed to Solved brody • 26 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...