tj / ejs

Embedded JavaScript templates for node
4.47k stars 513 forks source link

Error: Could not find include include file. #234

Closed vikicoder007 closed 6 years ago

vikicoder007 commented 6 years ago

Error on Console :

Error: Could not find include include file. at getIncludePath (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:152:13) at includeSource (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:276:17) at /home/cabox/workspace/node_modules/ejs/lib/ejs.js:629:26 at Array.forEach () at Template.generateSource (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:605:15) at Template.compile (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:509:12) at Object.compile (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:358:16) at handleCache (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:201:18) at Object.exports.render (/home/cabox/workspace/node_modules/ejs/lib/ejs.js:384:10) at Object.home (/home/cabox/workspace/app/includes/pages.js:18:16)

MY Code:

var pages = {
  login: function(data){
    var fs = require('fs');
    var viewCode = fs.readFileSync("./app/pages/login.ejs", 'utf-8');
    return ejs.render(viewCode,{data:data});
  },
  landing : function(req){
     var fs = require('fs');
    var viewCode = fs.readFileSync("./app/pages/landing.ejs", 'utf-8');
    return ejs.render(viewCode);
  },
  home: function(data) {
    var fs = require('fs');
    var viewCode = fs.readFileSync("./app/pages/home.ejs", 'utf-8');
    return ejs.render(viewCode,data);
  }
}

var viewCode = fs.readFileSync("./app/pages/home.ejs", 'utf-8'); Above file includes a navbar.ejs file which path is ./app/pages/inc/navbar.ejs

Code in home.ejs is <% include ./app/pages/inc/navbar.ejs %>

i got error on this so i change it to below path

<% include inc/navbar.ejs %>

again i got same error

how to resolve this ?

mde commented 6 years ago

This version of EJS is no longer maintained. The current version is here: https://github.com/mde/ejs

rutik-adhe commented 3 years ago

In my Case, OS Ubuntu, Path was like this

<%- include('/media/username/diskname/foldername/nodejsApp/views/body/header.ejs') %>

aaronGeb commented 1 year ago

How can i solve this ejs templet { "message": "/Users/muluneh/Web_Chat_app/webChatApp/views/index.ejs:1\n >> 1| <%- include ('./partials/header.ejs') %>\n 2| \n 3| <div id=\"login-container\">\n 4| <div id=\"left-column\"></div>\n\n/Users/muluneh/Web_Chat_app/webChatApp/views/partials/header.ejs:16\n 14| <body>\n 15| <div class=\"menu\">\n >> 16| <% if (loggedInUser && loggedInUser.username) { %>\n 17| <div class=\"menu-item\"><a href=\"/inbox\">Inbox</a></div>\n 18| <div class=\"menu-item\"><a href=\"/users\">Users</a></div>\n 19| <div class=\"menu-item\"><a href=\"#\" onclick=\"logout()\">Logout</a></div>\n\nloggedInUser is not defined" }

limitLam commented 1 year ago

这是来自QQ邮箱的假期自动回复邮件。您好,我暂时无法亲自回复您的邮件。我看到邮件后,尽快给您回复。

aaronGeb commented 1 year ago

https://github.com/mde/ejs Which language is it