Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: window is not defined #69

Closed
dougajmcdonald opened this issue Sep 14, 2015 · 8 comments
Closed

ReferenceError: window is not defined #69

dougajmcdonald opened this issue Sep 14, 2015 · 8 comments

Comments

@dougajmcdonald
Copy link

Hi there,

When I include the react-leaflet library I seem to get "ReferenceError: window is not defined".

This comes from leaflet-src.js as far as I can see, any ideas? Seems like I'm including something incorrectly.

ReferenceError: window is not defined
at Object. (C:\Applications\Nexus\Nexus\node_modules\leaflet\dist
\leaflet-src.js:9163:3)
at Module._compile (module.js:460:26)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js](C:Applications
NexusNexusnode_modulesbabelnode_modulesbabel-corelibapiregisternode.js:
214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (C:\Applications\Nexus\Nexus\node_modules\react-leafle
t\lib\index.js:9:16)
at Module._compile (module.js:460:26)
14 Sep 11:44:46 - [nodemon] app crashed - waiting for file changes before starti
ng...

@PaulLeCam
Copy link
Owner

Hi,

Please refer to #45 for more information.

@mhacxermood914
Copy link

mhacxermood914 commented Mar 16, 2021

This worked for me
1-i've installed jsdom-global using npm manager...

2-I've replaced window object by global object

then i resolve window ior document is not defined issues

Hope it would resolve your issue

@bertho-zero
Copy link

Or use https://www.npmjs.com/package/@react-leaflet/universal-leaflet

module.exports = typeof window === 'undefined' ? {} : require('leaflet')

@nyx6965
Copy link

nyx6965 commented Feb 12, 2022

It still shows an error.

@a0m0rajab
Copy link

This could hlep:
https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

@SheikhRashed
Copy link

This could hlep: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr
Thank you, It's work for me

@EthanDebnath
Copy link

what is the /header.js file?

@kleenkanteen
Copy link

This could hlep: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr

If you are using the app router, make sure to change the docs to app router version. and make sure you put the leaflet map in a separate component and dynamically import it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants