How do I add external node module, `discord.js` on a self-hosted `n8n`?

How do I properly add discord.js external node to n8n?

This is how I tried to add it:


ERROR: Cannot find module ‘discord.js’ [Line 2]


Hey @Norkz,

Have you installed the npm package? When you say hosted do you also mean cloud or self hosted?

I haven’t installed the npm package and I mean’t self-hosted.

Hey @Norkz,

I suspect that would be the issue then, You would need to install the npm package into your install and from there it will work. How you do that would depend on your installation method, It is a bit tricker to do if you use docker as you would need to make your own image but if you are using npm you should be able to install it like a normal npm package and you would be good to go.

Understood, thank you!

I will advise when I have fixed it.

Since I use Docker, would the following work?

Npm installation into a docker container

You might be able to get away with just using something like the below.

FROM n8nio/n8n:latest
RUN cd /usr/local/lib/node_modules/ && npm install discord.js
1 Like