leaflet-elevation icon indicating copy to clipboard operation
leaflet-elevation copied to clipboard

Cannot use this package with nextjs

Open THRY opened this issue 6 months ago • 1 comments

Hi, im trying to use this package within nextjs and i get an error.

I am installing the package like described in the FAQ-Section (How can I import this library as ES module?): const controlElevation = L.control.elevation({srcFolder: '/leaflet-elevation/src/' }).addTo(map);

Where the path in srcFolder points to the public nextjs folder, where i copied the package into.

I still get this error:

client.ts:59 ./node_modules/@raruto/leaflet-elevation/src/control.js:229:32
Module not found
  227 | 			case this.__LHOTLINE:    condition = typeof L.Hotline  !== 'function'; break;
  228 | 		}
> 229 | 		return condition !== false ? import(_.resolveURL(src, this.options.srcFolder)) : Promise.resolve();
      | 		                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  230 | 	},
  231 |
  232 | 	/**

Can you help me?

THRY avatar Jul 08 '25 12:07 THRY

Hi @THRY, I don't use leaflet with JS bundlers (it almost seems like a contradiction to me...).

Did you search among closed discussions? (it's quite an old / recurring topic).

To simplify, you can import all the necessary modules where you may need them, eg: https://github.com/Raruto/leaflet-elevation/issues/280#issuecomment-1831390419

👋 Raruto

Raruto avatar Jul 09 '25 08:07 Raruto