Failed Login with Error "Cannot find module..."

Last Updated: Oct 7, 2024

Overview

A common error can occur when an unsupported node module is being used in a Rule or Hook or a dependency has not been added in an Action. Logins will fail with the error beginning like this:

Cannot find module…

Applies To

  • Node Module
  • Actions
  • Hooks
  • Rules

Cause

An unsupported node module is used in a rule or hook, or a dependency has not been added to the action.

Also:
In actions, never require a dependency with the version suffix similar to those in legacy extensibility code (e.g., rules using canirequire). So, it is recommended to change the action code from:

const ManagementClient = require(“auth0@4.3.1”).ManagementClient;

to

const ManagementClient = require(“auth0”).ManagementClient;

The version of the Auth0 dependency is determined when adding the package to the action.

Solution

Follow the steps or video below.

Use a supported node module in the rule or hook. Refer to the supported modules.

For Actions, the dependency needs to be added.

In Actions, add the dependency.

  1. Click on the Dependencies icon on the left side of the edit screen.
    image

  2. Click the Add Dependency button.

  3. Enter the name and version of the dependency, for example:

1 Like