Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

306
Vistas
How to load and use modules in embedded JavaScript (EJS) code

My current scripts/codes flow is index.js->routes.js->main.ejs I need to load a GeoTiff-related module and use its plotting functions in my main.ejs. However I find that ejs does not support loading modules within the code, so I need to load the GeoTiff modules in my index.js or routes.js and render the functions to main.ejs.
I found some examples from Google and followed their methods but unfortunately I couldn't make it work. The error information keeps showing that the GeoTiff-related functions in main.ejs are not defined.

The github website of the module I try to use is here:

  • https://github.com/geotiff/georaster-layer-for-leaflet

As you can see in the Usage Example it directly require the georaster and then compose the plot functions in the same js code, whereas in my case my plot codes will be in my main.ejs where I can not require the georaster directly.

Following the method in this page:
https://rajuthapa-13222.medium.com/how-to-use-node-packages-on-ejs-html-templating-engine-d51885e91deb
I tried the following codes in my routes.js

var parse_georaster = require("georaster");
var GeoRasterLayer = require("georaster-layer-for-leaflet");

var getMain = function (req, res) {
   res.render('main',{parse_georaster: parse_georaster,GeoRasterLayer: GeoRasterLayer});
};

But it seems not working. I still can not use the function of parse_georaster and GeoRasterLayer in my main.ejs.

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda