Is NODE_FUNCTION_ALLOW_EXTERNAL not working for you? Maybe this is happening to you.

I was trying to install puppeteer on n8n (don’t ask me why) so I followed the steps I already knew:

  • docker compose down
  • docker compose up --build -d

But something strange happened, this package was saved in n8n as if it existed, for example, when I had a “code” type node in n8n and wrote const puppeteer = require(", the interface was able to suggest “require(‘puppeteer’)” as if it existed, but when I tried it I got a “Cannot Node Module Found” error. I decided to enter the docker container and check the internal files until I found that indeed n8n saved the fact that this module was supposedly installed, but when checking the node_modules folder the package was not there.

Anyway, the point is that I tried to install it manually with npm i puppeteer as root and got a compatibility error, and well n8n does not seem to explicitly inform you that there was an error installing a package (at least not as far as I saw), I simply tried to install with an npm i puppeteer --force then I restarted the container with docker restart and everything worked fine.

In summary:
Try to check the npm logs or try to install the package manually yourself and inspect the problem.

Solution 1:
You simply need to modify your Dockerfile to add a manual installation command with npm i [package] --force (or npm i [package] --legacy-peer-deps might also work).

Solution 2:
If for some strange reason you don’t want to do the above, you can do this, but keep in mind that the changes you make in the container this way will not remain when the container is rebuilt.

  1. We enter the container as root to have permissions to make changes
  • docker exec -u root -it [docker id] /bash/sh
  1. We go to the n8n installation
  • cd /usr/local/lib/node_modules/n8n/
  1. We install the package or packages we want
  • npm i [package] --force (or npm i [package] --legacy-peer-deps might also work)
  1. We verify the installation in node_modules
  • ls node_modules | grep “[package]”
  1. We exit the container
  • exit
  1. We restart the container (note: restart not rebuild)
  • docker restart [container id]

I hope this helps someone who is a bit lost on the subject.