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

Cannot run the project #404

Open
Ludus731 opened this issue Oct 10, 2024 · 2 comments
Open

Cannot run the project #404

Ludus731 opened this issue Oct 10, 2024 · 2 comments

Comments

@Ludus731
Copy link

Ludus731 commented Oct 10, 2024

I want to download map tiles using leaflet.offline:

  1. npm init in an empty project directory
  2. npm install leaflet.offline
  3. Create index.js with import 'leaflet.offline'
  4. Add "type": "module" to package.json
  5. node index.js

I’m getting an error:

C:\path\to\project\node_modules\leaflet\dist\leaflet-src.js:230
  var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;
                  ^

ReferenceError: window is not defined
    at C:\path\to\project\node_modules\leaflet\dist\leaflet-src.js:230:19
    at C:\path\to\project\node_modules\leaflet\dist\leaflet-src.js:7:66
    at Object.<anonymous> (C:\path\to\project\node_modules\leaflet\dist\leaflet-src.js:10:3)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at C:\path\to\project\node_modules\leaflet.offline\dist\bundle.js:2:85

Node.js v18.18.0

OS: Windows 10

@allartk
Copy link
Owner

allartk commented Oct 10, 2024

Seems you try to run on node and not in the browser?

The error is from leaflet itself, which should run in the browser.

@Ludus731
Copy link
Author

Seems you try to run on node and not in the browser?

Which file do I need to open in the browser after loading the package with npm install leaflet.offline? I only need to download and save the map tiles on my PC.

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

2 participants