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.

ReferenceError: navigator is not defined

See original GitHub issue

Bug report

Description / Observed Behavior

When building the app with NextJS in Jenkins, the build fails with the following error message:

ReferenceError: navigator is not defined
    at Object.641 (/app/node_modules/swr/dist/index.js:1:11816)
    at __webpack_require__ (/app/node_modules/swr/dist/index.js:1:154)
    at Object.516 (/app/node_modules/swr/dist/index.js:1:3661)
    at __webpack_require__ (/app/node_modules/swr/dist/index.js:1:154)
    at Object.325 (/app/node_modules/swr/dist/index.js:1:1394)
    at __webpack_require__ (/app/node_modules/swr/dist/index.js:1:154)
    at startup (/app/node_modules/swr/dist/index.js:1:291)
    at module.exports.202 (/app/node_modules/swr/dist/index.js:1:323)
    at Object.<anonymous> (/app/node_modules/swr/dist/index.js:1:333)
    at Module._compile (internal/modules/cjs/loader.js:959:30) {

Expected Behavior

The build should succeed

Repro Steps / Code Example

Or share your code snippet or a CodeSandbox link is also appreciated!

Additional Context

NextJS 9.1.5 SWR 0.2.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
huozhicommented, Jan 9, 2021

@lildata currently swr can only works very smoothly in browser runtime only (the time when I wrote this reply). the short unofficial work around could be:

useSWR(key, fetcher, {
  isOnline() { /* online detector for ink runtime */ },
  isDocumentVisible() { /* online detector for ink runtime */ },
})

making swr become more flexible for different runtime is still in progress 😃

0reactions
pkecommented, Nov 13, 2021

hmmm I don’t know. My jest tests ran just fine with react-native 0.63.3 and now started to fail with 0.66.3. My swr remained at version 0.4.2. All of the sudden all swr related tests fail.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - ReferenceError: navigator is not defined
Does this answer your question? require(processing-js) throws Reference Error: Navigator not Found. – tbking. Feb 25, 2020 at 16:36 · 2. What are ......
Read more >
Navigator is not defined----bug - Theia Community
navigator is a browser API. If you require code in the backend that ends up executing browser scripts you will get errors.
Read more >
navigator is not defined node js - You.com | The AI Search ...
If you're doing server side rendering then you need to call navigator in a function that is run on the client side. For...
Read more >
Error during timezone guessing [ReferenceError: navigator is ...
Check Error Console Actual Results: Error: Skipping Operating System timezone '(null)'. ReferenceError: navigator is not defined Source File: file:///[.
Read more >
Getting "ReferenceError: navigator is not defined" in Next.js app
Getting error - ReferenceError: navigator is not defined error from Plasmic in development and production for our NextJS app 3:18:27 PM: ...
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