Self is not defined - Bugsnag/js
See original GitHub issueSteps to reproduce
- I was trying to add bugsnag to my node api and i was following the steps mentioned here https://docs.bugsnag.com/platforms/javascript/
- Everything was working normally but suddenly i ran into this error when i started my hapi server with
npm start
- See error
Environment
-
Bugsnag version: 7.16.2
-
Server framework version (if any):
- Hapi ^16.0.3:
-
Node version : 14.19.1
-
Device : Apple M1 Pro macbook pro
I did not do anything crazy with the setup. I just installed bugsnag -> created a project in bugnsag dashboard -> went on with the steps mentioned in the docs.
Code:
var Bugsnag = require('@bugsnag/js');
Bugsnag.start({
apiKey: process.env.BUGSNAG_NOTIFIER_KEY,
appVersion: require('../package.json').version
});
Error messages:
ReferenceError · self is not defined
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Reference Error: self is not defined - javascript - Stack Overflow
self is likely referring to window which is not available on the server side...it's only available in a browser context.
Read more >'Server Error: Self is Not Defined' When Used During SSR
When used in an SSR build (NextJS in this case) the following error is thrown: Server Error ReferenceError: self is not defined.
Read more >Frequently asked questions - Bugsnag docs
Get help with your Bugsnag JavaScript integration and answers to frequently asked questions.
Read more >Developers - ReferenceError: self is not defined - - Bountysource
ReferenceError : self is not defined · Expected behavior. Our Webpack Server should start normally · Observed behavior. When running out dev server ......
Read more >ReferenceError: self is not defined - Blockcerts Forum
Hi all, I am running the server.js sample code for NodeJS and I get the following error: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hi @sayo96 - we’re struggling to see a mechanism by which this would occur, perhaps an IntelliCode plugin or similar autocompleted the
require
statement in your IDE? I found the original error in your Bugsnag dashboard and it looks like this occurred in a local development environment?I’m going to close this issue for now as the issue looks to be transient, but if you see this again and are able to provide us with a cut-down reproduction example demonstrating the issue we’d be more than happy to look into this further. Feel free to send this to support@bugsnag.com 👍
hi @sayo96 - do you
require
Bugsnag inside yourserver/controllers/tasks.js
file too? It looks like you’re using@bugsnag/browser
there which I think is where the issue lies. Could you update this to the following instead to see if that fixes the issue for you?