Installing additional module with npm

Hey @dickhoning, I think if both your module and n8n are globally installed, simply running something like export NODE_FUNCTION_ALLOW_EXTERNAL=modulename && n8n should do the job.

I haven’t tried this first hand as I am using the cloned Git repo on my machine. So just for reference and in case anyone wants to try my exact approach out, the below steps worked for me (assuming all dev setup steps are complete):

git clone [email protected]:n8n-io/n8n.git
cd n8n
npm install hello-world-npm
lerna bootstrap --hoist
npm run build
export NODE_FUNCTION_ALLOW_EXTERNAL=* && npm start

Afterwards, I could use this dummy module in n8n inside a Function node using code like this:

const helloWorld = require('hello-world-npm');
return [{
  json: {
    foo: helloWorld.helloWorld()
  }
}];

image

1 Like