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.

localStorage is not defined

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.11.0-next.1547527073587
  • Platform / OS version: Windows 10
  • Node.js version: 14.15.4

What steps will reproduce the problem?

Please include code that reproduces the issue.

`const config = require(“./config.json”);

const puppeteer = require(“puppeteer”);

(async () => { const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); await page.goto(“https://discord.com/app”); await page.evaluate(() => { localStorage.clear(); }); await page.goto(“https://discord.com/app”); })();`

What is the expected result? Localstorage should be cleared.

What happens instead? (node:9372) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: localStorage is not defined at puppeteer_evaluation_script:2:5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vsemozhetbytcommented, Feb 28, 2021

If you enter localStorage in the browser console while on https://discord.com/app you get the same error. It seems one of the site scripts deletes the window.localStorage property.

0reactions
mattys0229commented, Mar 2, 2021

if you still didn’t resolve your issue https://gist.github.com/Mathspy/55614eb2e9b8fc86c1dc814e50470ab1 can help you if you want to read from localStorage

Read more comments on GitHub >

github_iconTop Results From Across the Web

React - “localStorage is not defined” error showing
After this, I am getting the following error: ReferenceError: localStorage is not defined. Please help how to resolve it. My package.json :
Read more >
ReferenceError: localStorage is not defined in JavaScript
To solve the "ReferenceError: localStorage is not defined" error, make sure to only use the localStorage object in the browser. The localStorage property...
Read more >
How to Fix "localStorage is not defined" in Next.js
You've tried to use localStorage in your Next.js application and you're getting the following error: ReferenceError: localStorage is not defined ...
Read more >
localStorage is not defined - Next.js · Discussion #19911
Hi @danilo-leal. The issue you are seeing is because localStorage (aka window.localStorage ) is not defined on the server side. Next server ...
Read more >
window is not defined when I run `gatsby build` using ... - Reddit
On the serverside window is not defined. I would recommend setting `useState(null)` and adding a `useEffect`, that reads the localStorage when the page...
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