How to import external Library in global n8n?

Hi Team,

I want to import and use the external library in my workflow using the function node.
I am running n8n like below,

  1. npm i -g [email protected]
    2.n8n

then I created the workflow with this azure-devops-node-api library
showing this error.

version i used :
node - 14.x
n8n - 0.161.0
npm - 8.5.4

Even I run this npm i -g azure-devops-node-api with node version 14.
it will not work.
Any other way to install an external library and use it.

if I am running n8n with docker and used npm i -g azure-devops-node-api library.
It works as well.

Thanks… !!!

Hey @rajesh-kumar,

Using the -g option is not something that is directly supported, You will need to run the npm i command from inside the n8n node_modules directory (/usr/local/lib/node_modules/n8n) although this would depend on how you have n8n installed.

You also need to make sure the NODE_FUNCTION_ALLOW_EXTERNAL environment variable is set.

1 Like

Hey @Jon,

Yes.
1.npm i -g axios moment uuid node-svn-ultimate azure-devops-node-api
2.export NODE_FUNCTION_ALLOW_EXTERNAL=“axios,moment,uuid,node-svn-ultimate, azure-devops-node-api”

By running these I can able to use them in the function node.

Thanks for the help !!! @Jon

1 Like

Hey @rajesh-kumar,

Fantastic so is it working now? The last 2 issues with external librarys not working has been down to the environment variable not being set correctly.

1 Like

Yes, @Jon

Exactly.
Now it’s working fine.

1 Like

EDIT
Looks like this was because the wrong ecosystem.config.js file was loaded when I did a reboot after the update (Apache was hanging and couldn’t get it to act right) which loaded the old ecosystem.config.js file instead of the correct one. All is good now.

I just updated to 0.199.0 and now I get an error in my function nodes that are using the uuid external library. The error looks like this:
image

I double checked and the external library is listed in the ecosystem file:
image

1 Like