How to use multiple external npm packages

Install multiple npm dependencies

Hi, I wouldn’t say that I am new to n8n tool. I have some experience with it, but one thing was always pain to do. Install npm dependencies. In documentation I have found only information for that I have to set env variable NODE_FUNCTION_ALLOW_EXTERNAL to package name and thats all.

What are the steps?

What should I do to allow my n8n instance to install multiple npm packages? This should be pointed out in documentation what I should exactly do step by step to achieve this.

n8n setup

I recently use desktop n8n version, but I wanted to use npm packages so I moved on to docker version to be more flexible with n8n dependencies, config and deployment.

PS. I also have been searching a lot in this case, but I have been able to find only duplications of question for installation one specific package. And to be honest not clearly described.

Hi @Michu0112, welcome to the community :tada:

What should I do to allow my n8n instance to install multiple npm packages? This should be pointed out in documentation what I should exactly do step by step to achieve this.

It sems your goal is flexibility, so the easiest approach would be to set NODE_FUNCTION_ALLOW_EXTERNAL=*. This allows using all external modules that ship with n8n and is also what I do on my own instance.

If you’d rather specify which modules exactly you want to use you can separate their names using a comma (NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash).

Seeing you are using docker, these variables would have to be passed on to your container. If you are using the docker run command to launch n8n you can use the -e or --env option to do so, for example:

docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n -e NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash n8nio/n8n:0.208.1

You can then use these modules like so in the Code node:

If you need any modules not shipping with the default n8n docker image you would need to build a custom n8n docker image. This could be done as described over here by @hchris1.

Hope this helps!

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