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.

navigator not defined

See original GitHub issue

When used nw.js wrote in console

require('axios')({method: 'GET', 'url': 'https://google.com'}).catch(function () { console.log(arguments);})
lib$es6$promise$promise$$Promise {_id: 16, _state: undefined, _result: undefined, _subscribers: Array[0], constructor: function…}
VM298:2 [ReferenceError]0: ReferenceErrormessage: "navigator is not defined"stack: (...)get stack: function () { [native code] }set stack: function () { [native code] }__proto__: Errorcallee: function () { console.log(arguments);}length: 1Symbol(Symbol.iterator): function ArrayValues() { [native code] }__proto__: Object

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
laandercommented, Sep 11, 2015

I’m a little sad to see this closed. If the dist version isn’t safe for Node/CommonJS, it shouldn’t be built as an UMD module. I spent quite a few hours debugging this and it’s a false positives IMO. As a minimum there should be warning, a note in the README and it would be even better if the bug could be fixed (and thereby make Axios more embeddable into other UMD-ready libs)

1reaction
laandercommented, Jun 26, 2015

Related https://github.com/mzabriskie/axios/issues/58

IMO, it seems that the correct context isn’t read (browser vs. server) and the code assumes that its in browser context, thus using the xhr adapter that checks for navigator. Could it be somerthing to do with https://github.com/mzabriskie/axios/blob/master/package.json#L58 ?

I’m having the same problem when I’m developing a library that is built and bundled to both server and client (UMD target with webpack)

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - ReferenceError: navigator is not defined
I assume that the problem is that Navigator.geolocation is a Web API and doesn't work on node. Is there a way to mock...
Read more >
ReferenceError: navigator is not defined · Issue #522 · vercel/swr
Bug report Description / Observed Behavior When building the app with NextJS in Jenkins, the build fails with the following error message: ...
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 >
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
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 >

github_iconTop Related Medium Post

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