Pre-requisite
npm
Node.js 16
You will need dependency above on your Linux system, install by running command below
cd /tmp
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile
nvm install 16
sudo apt install npm -y
Installation
- Create a new directory
sudo mkdir /root/.n8n/nodes/external/node_modules
/root/.n8n/nodes/external/node_modules
sudo docker stop n8n
Please ensure you include dependency for the modules as well, otherwise you will not be able to use the it in N8N
docker run -d --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
-e GENERIC_TIMEZONE="America/New_York" \
-e TZ="America/New_York" \
-e NODE_FUNCTION_ALLOW_BUILTIN=* \
-e NODE_FUNCTION_ALLOW_EXTERNAL=* \
-v /root/.n8n/nodes/node_modules/[MODULE NAME]:/usr/local/lib/node_modules/[MODULE NAME] \
n8nio/n8n:latest
For example, I want to use node-fetch in n8n function node, these are the steps I took
https://www.npmjs.com/package/node-fetch
- Go to directory and install
cd /root/.n8n/nodes/node_modules
npm i node-fetch
docker run -d --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
-e GENERIC_TIMEZONE="America/New_York" \
-e TZ="America/New_York" \
-e NODE_FUNCTION_ALLOW_BUILTIN=* \
-e NODE_FUNCTION_ALLOW_EXTERNAL=* \
-v /root/.n8n/nodes/external/node_modules/data-uri-to-buffer:/usr/local/lib/node_modules/data-uri-to-buffer \
-v /root/.n8n/nodes/external/node_modules/fetch-blob:/usr/local/lib/node_modules/fetch-blob \
-v /root/.n8n/nodes/external/node_modules/formdata-polyfill:/usr/local/lib/node_modules/formdata-polyfill \
-v /root/.n8n/nodes/external/node_modules/node-domexception:/usr/local/lib/node_modules/node-domexception \
-v /root/.n8n/nodes/external/node_modules/node-fetch:/usr/local/lib/node_modules/node-fetch \
-v /root/.n8n/nodes/external/node_modules/web-streams-polyfill:/usr/local/lib/node_modules/web-streams-polyfill \
n8nio/n8n:latest