Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallListen for the page’s console event, then call msg.location() on the ConsoleMessage object. It returns a structured object with the message’s URL, line number, and column number when Puppeteer knows them. For additional stack locations, use msg.stackTrace().
Get a console message’s URL, line, and column
Browser-side console.* output does not automatically appear in Node.js. Puppeteer exposes it through page.on('console'); the event listener receives a ConsoleMessage. Call location() to retrieve its source coordinates:
page.on('console', msg => {
const location = msg.location();
console.log({
text: msg.text(),
url: location.url,
lineNumber: location.lineNumber,
columnNumber: location.columnNumber,
});
});
location() returns an object, not a formatted string. Its documented fields are url, lineNumber, and columnNumber. Each field is optional, so a value may be undefined when unavailable. Line and column numbers are zero-based; add one only when presenting them to people who expect one-based numbering, not when passing the values to tools expecting Puppeteer’s original coordinates. See the location() API and ConsoleMessageLocation interface.
Log missing values defensively
If you want the log to make an absent URL explicit without implying that Puppeteer found one, provide a display fallback:
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
page.on('console', msg => {
const {url, lineNumber, columnNumber} = msg.location();
console.log(msg.text(), {
url: url ?? '(unknown URL)',
lineNumber,
columnNumber,
});
});
The fallback changes only what is printed; the original API data remains optional.
Use stackTrace() when one location is not enough
msg.location() gives the concise location associated with the message. If you need the array of locations on the message’s stack, call msg.stackTrace() instead:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
page.on('console', msg => {
console.log(msg.text(), msg.stackTrace());
});
The method returns an array of locations, but the API does not promise that it will be non-empty for every message. Check for an empty array before assuming a frame is available. For compact structured logging, use location(); for investigating multiple stack locations, inspect stackTrace(). Both may provide incomplete information. See the stackTrace() API.
Keep browser and Node.js debugging distinct
The page event is the bridge for browser-side console messages: attach the listener to the Puppeteer Page you are debugging. If you need to inspect browser execution interactively rather than only capture logs, Puppeteer’s debugging guide describes launching with devtools: true and using a debugger statement.
Rank #3
The API pages consulted span Puppeteer documentation versions 25.1.0, 25.3.0, and 25.12.0. Check the API reference for the version installed in your project before relying on version-specific behavior.
Troubleshoot missing source coordinates
- URL or coordinates are undefined: treat them as unavailable metadata. The interface marks these fields optional; do not interpret their absence alone as a Puppeteer error.
- The stack array is empty: handle it as a valid case. The documented return type is an array, not a guarantee of at least one location.
- You cannot see browser logs in Node.js: verify that a
page.on('console', ...)listener is attached to the relevant page and that the output is generated by browser-side code. - The location is not the authored source you expected: the API documentation does not guarantee that a reported URL resolves to authored code rather than a generated resource, nor does it specify behavior for every browser, protocol, source-map configuration, or Puppeteer release.
- You need to step through execution: use the browser debugger approach in the official debugging guide in addition to collecting console events.
Or skip the browser setup
If your goal is a screenshot rather than capturing Puppeteer console coordinates, ScreenshotNeo offers a one-request screenshot API. For example, with cURL:
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo docs for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
Does msg.location() return a string?
No. It returns an object with optional url, lineNumber, and columnNumber fields.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsHow do I get a stack trace from a Puppeteer console message?
Call msg.stackTrace() in the page console event listener; check for an empty array before using its locations.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

