After uninstalling the package go back to module loader it shows the error Uncaught TypeError: Cannot set properties of undefined (setting 'create') and doesn't load properly.

Hello Everyone, 

When I uninstall the plugin it says module uninstall successfully but when I click on back to module loader then the error occurs. 

The error state that Uncaught TypeError: Cannot set properties of undefined (setting 'create')

and the piece of code is this

code located at public/custom/javascripts/<file_name>.js

(function(app) {
    app.events.on("app:sync:complete", function() {
        var userType = app.user.get('type');
        var uRoles = app.user.get('roles');
        var teams = app.user.get('my_teams');
        var acls = app.user.getAcls();
        if (userType == 'admin' || userType == 'user') {                
            if (acls) {
                acls.<module_name>.create = 'no';
                acls.<module_name>.edit = 'no';
                acls.<module_name>.delete = 'no';
            }
        }
    });
})
(SUGAR.App);
  • I got the answer after doing some research on it.

    the answer is

    (function(app) {
        app.events.on("app:sync:complete", function() {
            var userType = app.user.get('type');
            var uRoles = app.user.get('roles');
            var teams = app.user.get('my_teams');
            var acls = app.user.getAcls();
            if (userType == 'admin' || userType == 'user') {                
                /* if (acls) { */
                if (acls.hasOwnProperty('<module_name>') == true) {
                    acls.<module_name>.create = 'no';
                    acls.<module_name>.edit = 'no';
                    acls.<module_name>.delete = 'no';
                }
            }
        });
    })
    (SUGAR.App);