Add npm package to docker file

Hello guys,

I’ve deployed n8n through docker with this documentation :

Docker Compose | n8n Docs

And it’s running like a charm.

Now I would like to add this :

Adding it through the community browser doesn’t work.
It states that when running docker it should be added to the docker file :

"For Docker-based deployments, add the following line before the font installation command in your n8n Dockerfile:

RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-telepilot "

And I read in the threads here that since the latest version the Docker config is running under user ‘node’ instead of root.

How can I add this with regards to the setup as done in the documentation ?

thank you in advance,

Information on your n8n setup

  • **n8n version: : latest docker
  • Database (default: SQLite): : default
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • **Running n8n via : Docker
  • **Operating system:: Ubuntu 22:04

Hi @mr.dipp

Do you create a Dockerfile and use this Dockerfile in your docker-compose.yml ?

Hey,

thank you for your reply.

I created an docker-compose.yml as described here :

Docker Compose | n8n Docs

And copied the supplied content as described on #5 Create Docker Compose file

And created the .env file as #6 said with the required information in the .env file.

Thats it, nothing more…

If you want to install additionnal packages you can do it by create a Dockerfile like this for example :

FROM n8nio/n8n:1.14.2
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-telepilot
ENTRYPOINT ["docker-entrypoint.sh"]

And then in you docker compose file change line 27

n8n:
    image: docker.n8n.io/n8nio/n8n

by

n8n:
    build: .

Notice the “.” here means that you Dockerfile is in the same directory of your docker-compose file

Cool. Will try that.

Thank you for the support.

Hey Kent,

so I’m getting a bit further with this.

Now its complaining that it can’t access the /usr/local/lib/node_modules/ directory.
Now I’ve addes the USER root and change back to USER node to see if that helps.
It does insall the pythong make an npm etc etc.

But when it goes to the /user/local/node_modules directory it quits

[n8n 3/3] RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-telepilot:
37.49 npm ERR! code 1
37.49 npm ERR! path /usr/local/lib/node_modules/n8n/node_modules/tdl
37.49 npm ERR! command failed
37.49 npm ERR! command sh -c node-gyp-build
37.49 npm ERR! make: Entering directory ‘/usr/local/lib/node_modules/n8n/node_modules/tdl/build’
37.49 npm ERR! CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
37.49 npm ERR! make: Leaving directory ‘/usr/local/lib/node_modules/n8n/node_modules/tdl/build’
37.49 npm ERR! make: cc: No such file or directory

Now should I manually create the whole structure … or or … :slight_smile:

You have some advice on this area ?

Thanks !

FROM n8nio/n8n:latest
USER root
RUN apk add --update python3 py3-pip make npm
RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-telepilot
USER node
ENTRYPOINT [“docker-entrypoint.sh”]

Hello,

Why do you try to install python, pip and npm ? Yo juste need to install your missing package and it should work.
Npm is already install on docker images

Hey Kent1,

It was complaining that it couldn’t find make ( showed in the output ).
The python, npm etc is there now because of trial and error. I will remove it from the Dockerfile.

Dipp

Hey @mr.dipp,

The path you are using is not correct it should be…

RUN cd /home/node/.n8n/custom && npm install n8n-nodes-telepilot

But if you are installing a community node you can just do it from the n8n interface under the settings which is a lot easier, You can find that option here: GUI installation | n8n Docs

Goodmorning Jon,

thank you for the support, I will try that.

I did try to add it through the community browser, but it failed.
On gitbhub of Telepilot it said that if using the Docker route, it should be added during
the Docker n8n installation.

I did try the easy route first :smiley:

Hey @mr.dipp,

I have just given it a go and it fails to install from the UI for me as well, I guess the docker approach is the best option which is annoying.

Looking at the package on npm I forgot that this is one that includes some precompiled binaries so it would need the dockerfile route using the correct path.

Hey Jon,

thanks,

I’ve tried it with the cd /home/node/.n8n/custom path and with the cd /home/node/.n8n/ path.
But both fail

I’ve mailed the author of the Telepilot npm, maybe he has some pointers…

1 Like