Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

312
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!