navigator not defined
See original GitHub issueWhen 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:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop 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
Top GitHub Comments
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)
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)