Resolution for Auth0 Action "TypeError: cannot read properties of undefined"
Last Updated:
Overview
This article clarifies how to resolve an execution error that occurs when running a Post-Login Custom Action in Auth0. When the code attempts to use the Node.js cryptographic module, the following error message is displayed:
TypeError: cannot read properties of undefined (reading 'createHmac')
Applies To
- Auth0 Post-Login Custom Action
- Node 18 runtime
- Cryptographic operations
Cause
The error occurs because the Node 18 runtime in Auth0 Actions may not correctly initialize certain global modules or encryption methods. Node 18 is an outdated runtime and lacks built-in optimizations found in newer versions.
Solution
Upgrade the action's runtime environment to Node 22 to ensure compatibility with modern JavaScript cryptographic libraries. Review the Node.js 22 Migration Guide for detailed migration information.
NOTE: Module-level code in Actions is now invoked once per Action instance and may be reused as needed across multiple executions.
-
Go to the Auth0 Dashboard > Actions > Library.
-
Select the specific custom action.
-
Locate the yellow banner stating that the action was built using an outdated runtime.
-
Click Upgrade within the banner.
-
Verify the runtime description displays Node 22 (Recommended).
-
Click Deploy to push the changes to the login flow.