eligrey / FileSaver.js

An HTML5 saveAs() FileSaver implementation
https://eligrey.com/blog/saving-generated-files-on-the-client-side/
Other
21.69k stars 4.38k forks source link

ReferenceError: navigator is not defined #685

Open kaiyoma opened 4 years ago

kaiyoma commented 4 years ago

I'm upgrading from version 2.0.2 to 2.0.5 and suddenly my test framework is failing with this:

ReferenceError: navigator is not defined
    at .../node_modules/file-saver/src/FileSaver.js:72:60
    at .../node_modules/file-saver/dist/FileSaver.min.js:1:106
    at Object.<anonymous> (.../node_modules/file-saver/dist/FileSaver.min.js:1:154)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Module._compile (.../node_modules/pirates/lib/index.js:99:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Object.newLoader [as .js] (.../node_modules/pirates/lib/index.js:104:7)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
vince1995 commented 4 years ago

@jimmywarting it would be better to replace _global.navigator with typeof window !== "undefined".

dineshpannu commented 3 years ago

I'm getting the same issue. No longer works when rendering server-side.

piotrgodycki commented 1 year ago

still an issue even in 2.0.5