Auto install node_modules on boot

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:

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

1 Like

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

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.