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

849
Views
Reference Error variable is not defined with ejs and nodejs

I'm trying to send a variable from nodejs(expressjs) to html page with ejs. But i'm getting ReferenceError: ...... variable is not defined error.

folder structure:

  • node_modules

  • src

  • static-pages-server

    • static-pages-server.js
  • views

    • pages

      • journey-analize-report.ejs
    • partials

journey-analize-report.ejs:

<script type="text/javascript">
        console.log('<%-currentCulture%>');
</script>

static-pages-server.js:

   const express = require('express');
    const app = express();
    const bodyParser = require('body-parser');
    const ejs = require('ejs');
    var path = require('path');
    var currentCulture;
    
    app.get('/', function(req, res) {
    res.render("pages/journey-analize-report", {currentCulture:"Hello"});
});

Error:

 ReferenceError: D:\Project-UI\views\pages\journey-analize-report.ejs:46
            44|     <script type="text/javascript">
            45|         
         >> 46|         console.log('<%-currentCulture%>');
            47|   
        
        currentCulture is not defined
            at eval (eval at compile (D:\SeyirMobilNG-UI\node_modules\ejs\lib\ejs.js:662:12), <anonymous>:12:16)
            at journey-analize-report (D:\SeyirMobilNG-UI\node_modules\ejs\lib\ejs.js:692:17)
            at tryHandleCache (D:\SeyirMobilNG-UI\node_modules\ejs\lib\ejs.js:272:36)
            at View.exports.renderFile [as engine] (D:\SeyirMobilNG-UI\node_modules\ejs\lib\ejs.js:489:10)
            at View.render (D:\SeyirMobilNG-UI\node_modules\express\lib\view.js:135:8)
            at tryRender (D:\SeyirMobilNG-UI\node_modules\express\lib\application.js:640:10)
            at Function.render (D:\SeyirMobilNG-UI\node_modules\express\lib\application.js:592:3)
            at ServerResponse.render (D:\SeyirMobilNG-UI\node_modules\express\lib\response.js:1012:7)
            at D:\SeyirMobilNG-UI\static-page-server\static-pages-server.js:41:9
            at Layer.handle [as handle_request] (D:\SeyirMobilNG-UI\node_modules\express\lib\router\layer.js:95:5)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you should use this syntax

<%= currentCulture %>

But you used

<%-currentCulture%>
about 4 years ago · Juan Pablo Isaza Report
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!