How to add Puppeteer to Docker Container so I can run it in n8n Code Node Self-Hosting

Describe the problem/error/question

I am using Docker for the first time, and trying to self-host n8n, everything work good. However I cannot install puppeteer into the container/images.

What is the error message (if any)?

I tried everything from the internet, try creating a custom image with both puppeteer and n8n, try install puppeteer locally into n8n directory, try install globally, try install into container, try install into container root but still cannot use it in Code Node. PLEASE HELP!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

And my budget cannot afford hosting Google Function, so please help me install and run it locally please!

here, it is already installed

Hey @Minh_Nguy_n_D_c,

Have you told n8n it can use the puppeteer node package by setting the NODE_FUNCTION_ALLOW_EXTERNAL env option? Did you also install puppeer for npm using npm i -g in hre container?

oh how can I do that?

I installed the puppeteer using npm i -g already but it wont show up when I check in the directory

i added the env option and started a new container, installed puppeteer inside the docker desktop to the root directory then restart the container. still cannot be use

here and still nothing in the node_module

I even try this:

docker run -it --rm `
--name n8n `
-p 5678:5678 `
-e NODE_FUNCTION_ALLOW_EXTERNAL=puppeteer `
-v ~/.n8n:/root/.n8n `
-v /c/usr/lib/node/node_modules/n8n/node_modules/puppeteer:/usr/local/lib/node_modules/puppeteer `
-v /c/usr/local/lib/node_modules/n8n/node_modules/puppeteer-core:/usr/local/lib/node_modules/puppeteer-core `
docker.n8n.io/n8nio/n8n:latest

and get this in the directory: Screen Shot 2024-09-27 at 21.56.50

but still cannot use

Even tried this:

docker run -it --rm `
--name n8n `
-p 5678:5678 `
-e NODE_FUNCTION_ALLOW_EXTERNAL=puppeteer `
-v ~/.n8n:/root/.n8n `
-v /c/usr/lib/node/node_modules/puppeteer:/usr/local/lib/node_modules/n8n/node_modules/puppeteer `
-v /c/usr/lib/node/node_modules/puppeteer-core:/usr/local/lib/node_modules/n8n/node_modules/puppeteer-core `
docker.n8n.io/n8nio/n8n:latest

still no hope? anyone help???

Hey @Minh_Nguy_n_D_c

The data directory for n8n is /home/node/.n8n can you use this instead of /root/.n8n which will cause issues.

Mapping an external bind with the puppeteer package to n8n will also likely cause issues and is not recommended.

How did you originally add puppeteer to n8n did you make your own docker image which would be the recommended option?

Can you share the docker file you tried to use as well? I suspect this is still a configuration issue but we will need to work out exactly how you are adding it to work out where it is going wrong.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.