URL - Web API not available in n8n

I am trying to use the Javascript URL class in my Code node.

according to the documentation this feature is available since Node.js v10.0.0
Chrome 32, but it does not seem to be available on n8n because when I try to reference the class I got an error message: URL is not defined

I am using n8n v1.32.2 at the moment.

any Idea how to work around this issue?

  • n8n version: 1.32.2
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): docker
  • Operating system: Debian

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Leonardo_Schuler,

you need to load these first (as ‘required’). You can do that with the env variables as below:

NODE_FUNCTION_ALLOW_BUILTIN or
NODE_FUNCTION_ALLOW_EXTERNAL

So it would be something like this for the URL class:
NODE_FUNCTION_ALLOW_BUILTIN=url

Hope this helps! :raised_hands:

1 Like

I have included the env var:
NODE_FUNCTION_ALLOW_BUILTIN=*

but still not working

I was able to make it work, I had to manually import the module in order to make it work, I thought the import was done automatically (the documentation should be more clear about it.

in order to use this module:

const url = require('node:url');
let x = new url.URL("https://localhost/abc")
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.