The definitive guide to custom NPM modules for self-hosted instances

Hey @adomakins,

Welcome to the community :tada:

I am a big fan of this but can you maybe clean it up a little bit to keep it friendly :slight_smile:

I would also like to add an other option is to use a Dockerfile with

FROM n8nio/n8n:latest
USER root
RUN npm install -g ytdl-core
USER node

You can then update your Compose file replace image with build like below.

  n8n:
    container_name: n8n
    build: .
    restart: always
    ports:
      - 5678:5678
    environment:
      - NODE_FUNCTION_ALLOW_EXTERNAL=${NODE_FUNCTION_ALLOW_EXTERNAL}
      - N8N_HOST=${SUBDOMAIN}.${DOMAIN_NAME}
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
      - ${DATA_FOLDER}/local_files:/files

So now if you use the docker compose file commands it will automatically build your image with the latest version of n8n and your module.

4 Likes