Tesseract in n8n

how can i use tesseract on n8n

I use n8n self hosted in docker swarm and I’m in version 1.1.1
and added this variable in my env

  - NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash,moment-with-locales,node-tesseract-ocr

Did you install it? The environment variable only tells n8n that you are allowed to use it, it will not install it.

I installed using these two command,
apt-get install tesseract-ocr
npm install node-tesseract-ocr

After that, do I need to do anything else?

So you build your own Docker image? Or do you do that on the host machine? Because that would explain why it does not work.

my n8n is in docker

Ah yes, I understood that. But my question was if you did create your own Docker image and installed the dependencies in there (only like that n8n will have access to them) or if you installed them on your host machine (so directly on your computer, then n8n will not have access to them and it can not work).

Got it, I installed it directly on the machine, @jan would you be able to help me install it correctly? first time I try to do this using external node.

Hey @Ruan17,

You will need to create a custom docker image, Which may look something like the below which gets tesseract installed and the node package but doesn’t include language packges you would need to add that part.

FROM n8nio/n8n:latest

USER root
RUN apk add tesseract-ocr
RUN npm install -g node-tesseract-ocr
USER node

@Jon how can i create a stack for that node to use in portainer?

@Ruan17 that I don’t have an answer for, Portainer doesn’t fully support building custom docker images so you would need to build your image outside of Portainer (Can I build an image while deploying a stack/application from Git?) then include it.

Is there a way I can use this code even using portainer?

You would need to build the image outside of Portainer first, Sadly this is a limitation of Portainer and something we don’t have control over.

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