After setting NODE_FUNCTION_ALLOW_BUILTIN still get ERROR: axios is not defined

Describe the issue/error/question

I am trying to make an Axios request inside a function node and it gives the error “ERROR: axios is not defined”

I have reviewed the configuration documentation here

I am using NPM & PM2 to manage the running n8n and have added the env variables to the ecosystem.js file. This seems to be working at getting the environment variables into n8n because I can go into a function node and console log the values that were set.

~~ function node ~~
console.log('builtin: ',$env[‘NODE_FUNCTION_ALLOW_BUILTIN’]);
console.log('external: ', $env[‘NODE_FUNCTION_ALLOW_EXTERNAL’]);

~~ output ~~
Node: “Function” builtin: *
Node: “Function” external: axios

from the running folder (n8n) I checked the node_modules folder and confirmed that axios is listed there.

But I am still unable to get the function node to see Axios.
Is there something I am not doing right?

Additionally for troubleshooting purposes I stopped running via pm2 and tried my own startup script:

~~ ~~

Same result, I can console.log the env variables but it can’t see axios.

Information on your n8n setup

  • **n8n version: 0.177.0
  • Database you’re using (default: SQLite): SQLite
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm,, desktop app]: NPM & PM2

If you want more info on how I installed n8n you can check this video. UPDATED: Installing N8N (Nodemation) on my server 2022 - YouTube

Hi I followed the exact tutorial and I’m having the same issue getting Internal and External tools like Axios available within n8n functions.

Hey @johnnyk & @calvin,

Welcome to the community :raised_hands:

It should be working, can you share the workflow you are trying to run?

When you restarted the pm2 process did you do it with the update-env option as well? I have seen it do some odd things in the past where the OS has an option set and a process in pm2 shows it but doesn’t use it.

@Jon, Thanks for following up. Yes I used the update-env to make sure pm2 caught the updated environment variables.

Hey @johnnyk,

The first thing I have noticed is you have not actually declared Axios in your function, Try adding the line below to the top of your function node.

const axios = require('axois');

That was absolutely the issue. Thank you very much!

For my own future reference:

1 Like