question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preventing StackTrace is not defined on browser when using Browserify

See original GitHub issue

I’m trying to use this lib with Browserify + ES6 syntax.

import { StackdriverErrorReporter } from 'stackdriver-errors-js'

But, when I try to test it with some error I receive this:

Uncaught ReferenceError: StackTrace is not defined at StackdriverErrorReporter.report

image

Error line

Everything works fine when I use self-hosted CDN.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
tiescommented, Jun 6, 2017

After adding stacktrace-js as an dependency to package.json and adding the following line to my entrypoint it worked for me:

window.StackTrace = require('stacktrace-js');
0reactions
willycamargocommented, Jun 6, 2017

Hmm. I got it. You’re right!

But installing the module with npm will cause this error on any app, since that node_modules normally isn’t present on Client Apps when it is deployed to production.

Normallly packages installed by npm are used with AMD, CommonJS, etc. (using ES6 or no)

So the solution is provide the JS module architecture, as mentioned in #2

I guess I can do it in my free time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

require is not defined error with browserify - Stack Overflow
Longer answer: You are getting the error because the method require is not defined in the browser. You shouldn't include script.js .
Read more >
source-map-support - npm
Source Map Support. Build Status. This module provides source map support for stack traces in node via the V8 stack trace API.
Read more >
Browserify
Browserify lets you require('modules') in the browser by bundling up all of your dependencies. Install Documentation · Source Code · Help + Articles...
Read more >
API - esbuild
This API call is used by the command-line interface if no input files are provided and the --bundle flag is not present. In...
Read more >
A Gentle Browserify Walkthrough - Ponyfoo
bar.js console.log(i); // <- ReferenceError: i is not defined ... when it comes to using CommonJS in the browser through Browserify.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found