Docker-compose.yml - n8n_custom_extensions error

I am trying to install community_nodes manually.
But so far if I understand correctly I have to add in the n8n configuration NODE_FUNCTION_ALLOW_EXTERNAL AND N8N_CUSTOM_EXTENSIONS.
The problem is that if I add these two lines to my docker-compose.yml then n8n does not start at all on the server.
And adding to .env has no effect.

    - NODE_FUNCTION_ALLOW_EXTERNAL=*
    - N8N_CUSTOM_EXTENSIONS=/root/node_modules/n8n-nodes-puppeteer-extended

Hi @rafuru,
I haven’t tried using N8N_CUSTOM_EXTENSIONS to install external nodes like n8n-nodes-puppeteer-extended yet, but I created the repo n8n-puppeteer-docker some time ago to build/run a custom docker image with n8n-nodes-puppeteer installed.

Also the author of n8n-nodes-puppeteer-extended created a medium article how to build/run a docker image a couple of days ago.

The important part in the docker image is installing the chromium dependencies and finally install the npm package into the global n8n installation path. Be aware that the author uncommented the last line for some reason.

It looks like the N8N_CUSTOM_EXTENSIONS path expects the build output of custom nodes, so you could try mapping the dist folder.

You do not need NODE_FUNCTION_ALLOW_EXTERNAL to make this work. The config is for the Function node and if you can import external modules inside your javascript code there.

@marcus
N8N_CUSTOM_EXTENSIONS using any path causes n8n to not load at all. This is a very strange behavior because it should at most simply not load community nodes and not block n8n operation.

Hey @rafuru,

Do you see any messages in the log when it fails? I would expect there to be something if it is failing and not loading at all.

@Jon
Data from logs:

{"level":"info","message":"Initializing n8n process","metadata":{"file":"start.js","timestamp":"2022-09-30T14:34:54.769Z"}}
{"level":"debug","message":"No codex available for: N8nTrainingCustomerDatastore.node.js","metadata":{"file":"LoadNodesAndCredentials.js","function":"addCodex","timestamp":"2022-09-30T14:34:57.474Z"}}
{"level":"debug","message":"No codex available for: N8nTrainingCustomerMessenger.node.js","metadata":{"file":"LoadNodesAndCredentials.js","function":"addCodex","timestamp":"2022-09-30T14:34:57.475Z"}}

Hey @rafuru,

That is a lot less than expected, The 2 debug lines there I believe come from where we load the nodes so we can see that part is kind of working.

Does the container / service then just keep looping or does it stay like that?

@Jon
I have ‘restart: always’ configured and am using nginx.
When I set ‘N8N_CUSTOM_EXTENSIONS’ I get the nginx error page all the time (this is normal with me, it means that nginx doesn’t receive anything from the application) so n8n doesn’t start at all.

Hey @rafuru,

Perfect, So do you see those 3 lines repeating in the log or do you only see those 3? Repeating would tell me that it is crashing and restarting at that point, If it is just those 3 lines it would suggest it is still trying to load so it could be that something else is going on.

I take it you have the node files in place and the pre-req for the node is installed in your docker image?

@Jon
These 3 lines are repeated.

I installed n8n based on docker-compose and that’s it.
I have installed add-ons via community-node several times and removed them. Currently I have 1 add-on installed via UI.
And I wanted to try to install the add-on manually.
I installed via npm as instructed and wanted to add the path.

Hey @rafuru,

I have just given it a quick go and it appears to work how @marcus has suggested. On my Docker host I have created /home/docker/nodes/ and in there I ran…

git clone https://github.com/hckdotng/n8n-nodes-puppeteer-extended.git
cd n8n-nodes-puppeteer-extended/
npm i
npm run build

With the node now built I have then set up a volume in my container so that I can access /home/docker/nodes/ from /custom-nodes I have then set N8N_CUSTOM_EXTENSIONS=/custom-nodes/n8n-nodes-puppeteer-extended/dist/nodes/Puppeteer, Started my container up and I can see the below.

image

As another test I have deleted that attempt and just ran npm install n8n-nodes-puppeteer-extended then set N8N_CUSTOM_EXTENSIONS=/cuistom-nodes/ and that has also worked.

Can you share the steps you followed?

@Jon
The steps I have taken now:

  • I created /home/docker/nodes.
  • I installed there via npm install n8n-nodes-puppeteer-extended.
  • I added to my docker-compose two lines from custom extensions and from volume.
  • I restarted the container

Now n8n starts correctly while it does not see this node in the panel.

My docker-compose

version: "3"

services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "127.0.0.1:5678:5678"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=<hidden>
      - N8N_BASIC_AUTH_PASSWORD=<hidden>
      - N8N_HOST=<hidden>
      - N8N_PROTOCOL=https
      - NODE_ENV=production
      - WEBHOOK_URL=<hidden>
      - N8N_LOG_LEVEL=debug
      - N8N_LOG_OUTPUT=file
      - N8N_CUSTOM_EXTENSIONS=/custom-nodes/n8n-nodes-puppeteer-extended/dist/nodes/Puppeteer
    volumes:
      - ${DATA_FOLDER}/.n8n:/home/node/.n8n
      - ${DATA_FOLDER}/.n8n/local-files:/files
      - /home/docker/nodes:/custom-nodes

The path in custom_extensions is full to Puppeteer as you have shown because otherwise the logs return a

{ "level": "debug", "message": "No codex available for: Puppeteer.node.js","metadata":{"file":"LoadNodesAndCredentials.js","function":"addCodex","timestamp":"2022-10-01T12:28:38.359Z"}}

Hey @rafuru,

The codex error luckily doesn’t matter, I am not sure why the node is not showing for you though it looks like it is finding it which is a good start.

I take it you restarted the container and did a full refresh of the browser window?

@Jon
I always doing docker-compose down and then docker-compose up -d.
I tried a few times. Always opening new tab after building container.

Hey @rafuru,

I am not sure what else it could be, I know for me once the container was restarted I had to do a cmd+shift+r to force a refresh for the node to show up.

What happens if you just point it to /custom-nodes and let it work it out itself?