Skip to content

docs(BestPractices.md): add dependency caching guide #1101

Description

@yxliang01

To avoid performing npm install again and again when any source code in the project is being modified, it's (always?) preferred to cached node_modules as long as package.json and package-lock.json are not changed. I think this can be added to the BestPractices.md guide. Welcome for discussions on whether this is really a good practice also.

Activity

  1. yosifkit commented on Aug 28, 2019

    @yosifkit
    Contributor

    That is what the deprecated onbuild images would do. Perhaps it needs to be dropped into the best practices doc (minus the ONBUILD keyword)?

    Or just update the Dockerfile in the how-to-use this image section, since that two line Dockerfile doesn't really containerize an app unless it has a COPY.

  2. MikeMcC399 commented on May 5, 2026

    @MikeMcC399
    Contributor

    It would probably require extensive documentation to cover best practices for different package managers including the commonly-used npm, Yarn Classic, Yarn Modern (also with Plug'n'Play) and pnpm.

    Caching node_modules can lead to issues when post-installation scripts are associated with npm modules, and these are not executed if the module is found to be pre-installed. This can lead to malfunction.

    Leaving open as a general suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions