# Auto install node\_modules on boot

**URL:** <https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917>\
**Category:** General\
**Tags:** docker\
**Created:** [2 September 2025 18:25 UTC](https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917 "2025-09-02T18:25:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slyke](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Slyke](https://discourse.nodered.org/u/Slyke)\
**Post date:** [2 September 2025 18:25 UTC](https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917/1 "2025-09-02T18:25:26Z")

</div>

In the latest update, when importing a flow, it asks the user if they want to also install the nodes that the flow uses.

Is there any way to do this without a separate process or bootstrap script? I don’t want to check in the node\_modules directory into the repo.

Here’s my docker compose solution currently:

```auto
services:
  nodered-deps:
    image: node:22-bookworm-slim
    container_name: nodered-deps
    working_dir: /data
    environment:
      - npm_config_cache=/data/.npm
    volumes:
      - ./volumes/nodered:/data
    command: >
      bash -lc '
        set -euo pipefail
        if [-f package-lock.json]; then
          echo "[deps] npm ci"
          npm ci
        elif [-f package.json]; then
          echo "[deps] npm install"
          npm install --omit=dev --no-audit --no-fund
        else
          echo "[deps] no package.json; skipping"
        fi
      '

  nodered:
    image: nodered/node-red:4.1.0-22
    container_name: nodered
    restart: unless-stopped
    ports:
      - "1880:1880"
    environment:
      - TZ=UTC
    env_file:
      - .env
    volumes:
      - ./volumes/nodered:/data
    depends_on:
      nodered-deps:
        condition: service_completed_successfully

```

---

<div class="post-metadata">

**Author:** ![AllanOricil](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/allanoricil/32/106911_2.png) [@AllanOricil](https://discourse.nodered.org/u/AllanOricil)\
**Post date:** [3 September 2025 01:17 UTC](https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917/2 "2025-09-03T01:17:16Z")

</div>

Another solution could be a custom Docker file that always runs your npm install command. You could try to base it using the node-red container

---

<div class="post-metadata">

**Author:** ![Slyke](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Slyke](https://discourse.nodered.org/u/Slyke)\
**Post date:** [3 September 2025 14:44 UTC](https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917/3 "2025-09-03T14:44:51Z")

</div>

Yeah, that is what I did at first, but if that ever changes Node-RED side, will need to update the script. I figured a separate process just running `npm install` was safest for now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 December 2025 14:45 UTC](https://discourse.nodered.org/t/auto-install-node-modules-on-boot/98917/4 "2025-12-02T14:45:24Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
