Files
Jason Schell aaa9af208f Env vars for Code node if using Task Runners (#3629)
Co-authored-by: Justin Ellingwood <justin@n8n.io>
2025-09-11 10:01:48 +01:00

1.2 KiB

title, description, contentType
title description contentType
Enable modules in Code node Allow the use of both built-in and external modules within the Code node. howto

Enable modules in Code node

For security reasons, the Code node restricts importing modules. It's possible to lift that restriction for built-in and external modules by setting the following environment variables:

  • NODE_FUNCTION_ALLOW_BUILTIN: For built-in modules
  • NODE_FUNCTION_ALLOW_EXTERNAL: For external modules sourced from n8n/node_modules directory. External module support is disabled when an environment variable isn't set.
# Allows usage of all builtin modules
export NODE_FUNCTION_ALLOW_BUILTIN=*

# Allows usage of only crypto
export NODE_FUNCTION_ALLOW_BUILTIN=crypto

# Allows usage of only crypto and fs
export NODE_FUNCTION_ALLOW_BUILTIN=crypto,fs

# Allow usage of external npm modules.
export NODE_FUNCTION_ALLOW_EXTERNAL=moment,lodash

/// note | If using Task Runners If n8n instance is setup with Task Runners, add the environment variables to the Task Runners instead to the main n8n node. ///

Refer to Environment variables reference for more information on these variables.