Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: module is not defined on loading angular-permission.js #249

Closed
albv opened this issue May 16, 2016 · 5 comments
Closed

Comments

@albv
Copy link

albv commented May 16, 2016

I'm trying to upgrade from 2.3 but get this error message. Same problem with angular-permission-ui.js

@albv
Copy link
Author

albv commented May 17, 2016

Fix in 3.1.1 doesn't work for me either. Same error on the line

var _module = module || {};

I think this should be

var _module = typeof module !== 'undefined' ? module : {};

@albv
Copy link
Author

albv commented May 17, 2016

Also I think it's not good to pollute global scope with _module variable. Maybe we could use local var?

@jstroem
Copy link
Contributor

jstroem commented May 17, 2016

@masterspambot @albv It should be var module = module || {}, its the only way this works, since if the variable module is not defined prior var module = module || {} will not give you a referenceError while var _module = module || {} will.
However the idea that pulling the variable declaration inside of the function scope is sound and a good idea.

@kaynz
Copy link

kaynz commented May 17, 2016

Using var module = module || {} leads to Failed to instantiate module permission.ui

@albv
Copy link
Author

albv commented May 17, 2016

@jstroem @masterspambot If I am not missing something, export could be as simple as

if (typeof module !== 'undefined' && module.exports) {
  module.exports = permission.name;
}

neither IIFE nor local var required.

masterspambot added a commit that referenced this issue May 17, 2016
chore: Bump version to 3.1.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants