External CLI tools in n8n

@vuchl Hi, i recently figured this out as well, how to use external npm packages, with help from @jan.

This is how i implement it now:

1.Create Dockerfile in the same folder as your docker-compose.yml

Dockerfile content:

FROM n8nio/n8n

RUN npm install -g he
RUN npm install -g uuid
RUN npm install -g object-deep-compare
RUN npm install -g validator
RUN npm install -g gm
RUN npm install -g node-qpdf
RUN npm install -g dayjs
RUN npm install -g generate-unique-id

2.Build the docker image with this command:

docker build -t n8np .

^ ‘n8np’ is a chosen name…could be anything. Don’t forget the ’ . ’ at the end (i did).

3.Modify in docker-compose.yml :

n8n:
    image: n8np

4.Modify in .env :

NODE_FUNCTION_ALLOW_EXTERNAL=dayjs,lodash,he,uuid,object-deep-compare,validator,gm,node-qpdf,generate-unique-id

5.That’s it. You can start your docker containers now with:

docker-compose up -d

And everytime you need to upgrade n8n to a newer version:

docker pull n8nio/n8n
docker build -t n8np .
docker-compose stop
docker-compose rm
docker-compose up -d
9 Likes