Note that there are some explanatory texts on larger screens.

plurals
  1. POEJS module not found on OpenShift NodeJS template
    text
    copied!<p>I am unable to use EJS as my view render engine on NodeJS.</p> <p>I have found several similar questions but all state about installing EJS that really work for others. This is not same for me, may be because I am unable to choose the right directory (among so many duplicates in OpenShift repo) for the installation.</p> <p>I have NodeJS default app created by OpenShift template. While installing EJS dependency I somehow screwed it and I get following error (standard NodeJS error for unavailable module):</p> <pre> Error: Cannot find module 'ejs' at Function._resolveFilename (module.js:337:11) at Function._load (module.js:279:25) at Module.require (module.js:359:17) at require (module.js:375:17) at View.templateEngine (/usr/lib/node_modules/express/lib/view/view.js:134:38) at Function.compile (/usr/lib/node_modules/express/lib/view.js:68:17) at ServerResponse._render (/usr/lib/node_modules/express/lib/view.js:417:18) at ServerResponse.render (/usr/lib/node_modules/express/lib/view.js:318:17) at /var/lib/openshift/5123c2494382ec16ca000222/app-root/runtime/repo/server.js:114:17 at callbacks (/usr/lib/node_modules/express/lib/router/index.js:272:11) </pre> <p>Besides mentioning in package.json, I tried installing ejs through terminal at app-root, runtime and nodejs-0.6 level as well (and restarting of the app), but of no use.</p> <p>My directory structure is:</p> <pre> -app-root ---data ---repo -----node_modules (has ejs) -----server.js -----package.json ("dependencies": {"ejs" : ">=0.8.3"},) -----views -------defaultError.ejs ---runtime -----data -----node_modules (empty) -----repo (identical to app-root/repo) -------node_modules (has ejs) -nodejs-0.6 ---data ---repo (identical to app-root/repo) -----node_modules (has ejs) ---runtime -----node_modules (empty) -----repo (identical) -------node_modules (has ejs) </pre> <p>defaultError.ejs is just plain html. server.js has following:</p> <p><code></p> <pre><code>self.createRoutes = function() { self.routes = { }; //... self.routes['/'] = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.send(self.cache_get('index.html') ); }; self.routes['/helloejs'] = function(req, res){ res.render('defaultError', { layout:false } ); }; }; self.initializeServer = function() { self.createRoutes(); self.app = express.createServer(); self.app.set('view engine', 'ejs'); // Add handlers for the app (from the routes). for (var r in self.routes) { self.app.get(r, self.routes[r]); } }; </code></pre> <p></code></p> <p>Hope this long post makes my problem clear :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload