Skip to content

Raven throws "module is not defined" #287

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

Closed
vitalybe opened this issue Nov 9, 2014 · 9 comments
Closed

Raven throws "module is not defined" #287

vitalybe opened this issue Nov 9, 2014 · 9 comments

Comments

@vitalybe
Copy link

vitalybe commented Nov 9, 2014

Occurs in master branch, 5390681 due to the code from PR #261:

} else if (isObject(module)) {
    // browserify
    module.exports = Raven;
} else if (isObject(exports)) {
    // CommonJS
    exports = Raven;
} 

To fix, it should be replaced with:

} else if (isObject(window.module)) {
    // browserify
    module.exports = Raven;
} else if (isObject(window.exports)) {
    // CommonJS
    exports = Raven;
} 
@mattrobenolt
Copy link
Contributor

So... I don't know everything here, but I'm pretty sure this will break browserify.

In what context did this break for you? Browserify does not let you use window.

@clayzermk1?

@mattrobenolt
Copy link
Contributor

Wait, yeah, this 100% won't work. wtf

@mattrobenolt
Copy link
Contributor

We have to replace these with explicit typeof checks instead of using isObject.

@mattrobenolt
Copy link
Contributor

To avoid the ReferenceError. Ugh.

@mattrobenolt
Copy link
Contributor

@vitalybe How's f6e8cbe look?

@clayzermk1
Copy link
Contributor

Just for reference, I had no trouble with a build of master that used the isObject calls using browserify.

Just for a sanity check, I'll build f6e8cbe tomorrow and check it out on browserify - I don't anticipate any issues.

@mattrobenolt
Copy link
Contributor

If module existed, it wouldn't fail. This will 100% fail with a ReferenceError if it was left undefined. Which is why I needed to replace it with explicit typeof checks and can't use isObject.

Did I mention that I hate JavaScript before? 👍

@clayzermk1
Copy link
Contributor

f6e8cbe looks to be working fine here.

@vitalybe
Copy link
Author

Looks good :)

matghaleb pushed a commit to matghaleb/raven-js that referenced this issue Sep 9, 2015
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