localStorage is not defined
See original GitHub issueSteps 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:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >
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 Free
Top 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

If you enter
localStoragein the browser console while on https://discord.com/app you get the same error. It seems one of the site scripts deletes thewindow.localStorageproperty.if you still didn’t resolve your issue https://gist.github.com/Mathspy/55614eb2e9b8fc86c1dc814e50470ab1 can help you if you want to read from localStorage