1

Locally I needed to fix a bug in an npm package, but when uploading the server to heroku, the npm gets reinstalled and my fix is of course gone. Is there a way to edit the file inside the node_modules folder inside heroku?

asked Mar 24, 2022 at 12:00

2 Answers 2

1

You should use patch-package package for that https://www.npmjs.com/package/patch-package

answered Mar 24, 2022 at 12:25
Sign up to request clarification or add additional context in comments.

Comments

0

I don't think patch-package by itself solves the problem you encountered. The problem is described in this issue logged in the patch-package project: https://github.com/ds300/patch-package/issues/130

It says:

When using Heroku's Node buildpack, by default the following will happen during the build and startup process:

  1. install all dependencies (including devDependencies) with yarn --production="false"
  2. run build step
  3. prune dev dependencies with yarn --production="true"
  4. run the app

However, at step 3 when the dev dependencies are pruned, the buildpack also specifies the --ignore-scripts flag when calling yarn (since v119). This means [your post-install script] will not run, because the postinstall/prepare scripts will not be ran. In turn, this means when the app runs, Node modules will not be patched (!).

As per the 'Skip Pruning' section of this Heroku doc, you can set environment variables to skip pruning. Alternatively, you might be able to (re-)apply your patch in the "heroku-postbuild" step.

answered Aug 21, 2023 at 18:25

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.