Cannot find module 'auth0@2.24.0'in Rule

Sometimes Cannot find module ‘auth0@2.24.0’ error occurs with the following code in Rules.

Why is the error occured and How can I fix?


const ManagementClient = require('auth0@2.24.0').ManagementClient;

Possible another rule that is causing the issue? See this thread:

Let’s start from the beginning.

Where do you get that error? How do you know that it’s coming from Rules?

I found the error in log page. My rule is the below

function (user, context, callback) {
  const ManagementClient = require('auth0@2.24.0').ManagementClient;
  const management = new ManagementClient({
    token: auth0.accessToken,
    domain: auth0.domain
  const params = { id: user.user_id };
  const data = { roles: ["role_id"] };
  management.users.getRoles(params, function(err, roles) {
  	if (roles === undefined) {
      management.users.assignRoles(params, data, function(err, assignedUser) {
        context.authorization.roles = ['__role__'];
        callback(null, user, context);
    } else {
      callback(null, user, context);

Is it working for you now?


When I run the following code, I see the same “ERROR: Cannot find module ‘auth0@2.24.0’” error message as you do.

function (user, context, callback) {
const ManagementClient = require(‘auth0@2.24.0’).ManagementClient;
console.log(‘mgmt’, ManagementClient);
return callback(null, user, context);

if I change the code from “auth0@2.24.0” to “auth0@2.23.0” then the error will be resolved.

It seems version 2.24.0 is not available in the Rules.
You can check available modules in Rules in the following site.



Thanks for providing that knowledge @shunsuke.tsutsui!

@shunsuke.tsutsui, @konrad.sopala
Thanks for the detailed explanation. I understand the problem now.

1 Like

No worries! We’re here for you!

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