Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module EJS #910

Closed
powmedia opened this issue Nov 30, 2011 · 11 comments
Closed

Cannot find module EJS #910

powmedia opened this issue Nov 30, 2011 · 11 comments

Comments

@powmedia
Copy link

I'm getting the 'Cannot find module EJS' error when trying to render a page.

Installing EJS globally, or installing it a level above my app.js file fixes this issue. Here is a stackoverflow question from someone else who had the problem:

http://stackoverflow.com/questions/7754799/error-cannot-find-module-ejs

@tj
Copy link
Member

tj commented Nov 30, 2011

if you can require('ejs') it in your app.js file express should be able to find it just fine

@tj
Copy link
Member

tj commented Nov 30, 2011

hmm it kinda looks like it's using a globally installed express..

@powmedia
Copy link
Author

It's a bit strange - I've tried requiring EJS from my app.js file and although it's in the main node_modules folder the require now fails as soon as the app starts. Moving EJS back out to a node_modules a level above my app.js fixes it.

This is on a new machine so I haven't installed Express or EJS globally.

@tj
Copy link
Member

tj commented Nov 30, 2011

looks global to me "/Users/shamoon/local/node/lib/node_modules/express"

@tj
Copy link
Member

tj commented Nov 30, 2011

that should be "/Users/shamoon/Sites/soldhere.in/node_modules/express"

@powmedia
Copy link
Author

Oh yeah I see what you mean - that's not the error I submitted on stackoverflow, that was someone else who seemed to be having the same problem.

Here's my stack trace:
500 Error: Cannot find module 'ejs'
at Function._resolveFilename (module.js:326:11)
at Function._load (module.js:271:25)
at require (module.js:355:19)
at View.templateEngine (/Users/charlie/Work/Pow/api/node_modules/express/lib/view/view.js:133:38)
at Function.compile (/Users/charlie/Work/Pow/api/node_modules/express/lib/view.js:65:17)
at ServerResponse._render (/Users/charlie/Work/Pow/api/node_modules/express/lib/view.js:414:18)
at ServerResponse.render (/Users/charlie/Work/Pow/api/node_modules/express/lib/view.js:315:17)
at /Users/charlie/Work/Pow/site/controllers/main.js:9:13
at callbacks (/Users/charlie/Work/Pow/site/node_modules/express/lib/router/index.js:272:11)
at param (/Users/charlie/Work/Pow/site/node_modules/express/lib/router/index.js:246:11)

@powmedia
Copy link
Author

One point I've just thought of that may be applicable - I'm mounting a second Express app (api) within a main Express app (site)

@tj
Copy link
Member

tj commented Nov 30, 2011

hmm yeah that might have something to do with it, bottom-line is that if you can require() it in that app, express can get it, so that's definitely the first thing to resolve

@joshbirk
Copy link

joshbirk commented Feb 1, 2012

Just a note:

I've got: require('ejs') and app.set('view engine', 'ejs') - and I still get this error. For me, it was having a globally installed express. global express + any kind of ejs resulted in the module not being found when using render(). Locally installed both seemed to work.

@tj
Copy link
Member

tj commented Jun 17, 2012

This issue has been inactive for over 4 months so I'm closing it. If you think it's still an issue re-open.

  • tjbot

@tj tj closed this as completed Jun 17, 2012
@dougwilson
Copy link
Contributor

Open a new issues with complete information so we can better assist you. This issue is 6 years old and Express and things like ejs have changed a fair bit in that time.

@expressjs expressjs deleted a comment from Mohib008 Jul 31, 2018
@expressjs expressjs deleted a comment from Mohib008 Jul 31, 2018
@expressjs expressjs deleted a comment from Mohib008 Jul 31, 2018
@expressjs expressjs locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants