DEV Community

Muhammad
Muhammad

Posted on

How to deploy a node app on Heroku which uses 'pnpm' as its package manager instead of 'npm'?

*Short answer:-
*

You have to install a third-party buildpack which can run pnpm commands from Heroku Elements e.g. https://elements.heroku.com/buildpacks/unfold/heroku-buildpack-pnpm

*Long answer:-
*

Normally, developers use "npm" as a package manager for their NodeJS apps.

However there is a new package manager in the market getting popular called "pnpm" (https://pnpm.io).

If you use "pnpm" instead of "npm" and want to deploy your NodeJS app to Heroku, the deployment will fail because the Heroku buildpack which runs the "install" command to start the deployment does it by assuming "npm" as your package manager.

As of 28-Jan-2023, Heroku's official NodeJS buildpack does not support the "pnpm" package manager, so you will have to add a third-party buildpack like this one:- https://elements.heroku.com/buildpacks/unfold/heroku-buildpack-pnpm

You can add the third-party buildpack through the dashboard or through your Terminal.

Wishing you success!

Top comments (2)

Collapse
 
socertis profile image
socertis

the max. version of node that this buildpack run is 16, which is very old now.

Collapse
 
socertis profile image
socertis • Edited

I have found another alternative that supports newer node version.
heroku buildpack