Add npm package in docker-compose

Hi @pooria, to use external modules in n8n you’d need to set the NODE_FUNCTION_ALLOW_EXTERNAL environment variable.

I’ve given this a quick go on my side and could run the following workflow as expected:

Result:

This was the exact Dockerfile I have used:

FROM n8nio/n8n:1.24.1
USER root
RUN npm install -g @tryfabric/martian
USER node

This was my docker-compose.yml:

services:
  n8n:
    build: .
    environment:
      - NODE_FUNCTION_ALLOW_EXTERNAL=*
    volumes:
      - ./data:/home/node/.n8n
    ports:
      - 5678:5678

After running docker compose build and docker compose up my n8n instance started as expected and I could run the above example workflow.

Hope this helps!

2 Likes