Cannot find 'ejs' module - Node.js application on Heroku

My application worked locally, but when I deployed to Heroku, a problem arose. That was my fault. It seems that the error was caused by what I could not do after adding EJS.

2014-01-06T16:53:39.285571+00:00 app[web.1]: module.js:340
2014-01-06T16:53:39.285956+00:00 app[web.1]:     throw err;
2014-01-06T16:53:39.286233+00:00 app[web.1]:           ^
2014-01-06T16:53:39.288439+00:00 app[web.1]: Error: Cannot find module 'ejs'
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at require (module.js:380:17)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:28:20)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-01-06T16:53:39.288439+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-01-06T16:53:39.288617+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-01-06T16:53:40.650512+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-06T16:53:40.637888+00:00 heroku[web.1]: Process exited with status 8
2014-01-06T16:53:40.651134+00:00 heroku[web.1]: State changed from crashed to starting
2014-01-06T16:53:42.536106+00:00 heroku[web.1]: Starting process with command `node app.js`
2014-01-06T16:53:43.447621+00:00 app[web.1]:
2014-01-06T16:53:43.449816+00:00 app[web.1]: Error: Cannot find module 'ejs'
2014-01-06T16:53:43.447621+00:00 app[web.1]: module.js:340
2014-01-06T16:53:43.447926+00:00 app[web.1]:     throw err;
2014-01-06T16:53:43.447926+00:00 app[web.1]:           ^
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-01-06T16:53:43.449990+00:00 app[web.1]:     at Function.Module.runMain (module.js:497:10)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at require (module.js:380:17)
2014-01-06T16:53:43.449816+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:28:20)
2014-01-06T16:53:44.712427+00:00 heroku[web.1]: State changed from starting to crashed
2014-01-06T16:53:44.700963+00:00 heroku[web.1]: Process exited with status 8
2014-01-06T16:54:13.976150+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=bruxzir-express.herokuapp.com fwd="98.173.1.66" dyno= connect= service= status=503 bytes=
2014-01-06T16:54:29.109297+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=bruxzir-express.herokuapp.com fwd="98.173.1.66" dyno= connect= service= status=503 bytes=
2014-01-06T16:54:29.243506+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=bruxzir-express.herokuapp.com fwd="98.173.1.66" dyno= connect= service= status=503 bytes=

After reading this question on SO, I needed to add this dependency to package.json. And to the ejs version, I started npm listand got this, which looks like there might be more errors for addressing.

application-name@0.0.1 /Users/juan.gallardo/Desktop/myfiles/test-projects/bruxzir-express-test
β”œβ”€β”€ ejs@0.8.5 extraneous
β”œβ”€β”¬ express@3.4.4
β”‚ β”œβ”€β”€ buffer-crc32@0.2.1
β”‚ β”œβ”€β”¬ commander@1.3.2
β”‚ β”‚ └── keypress@0.1.0
β”‚ β”œβ”€β”¬ connect@2.11.0
β”‚ β”‚ β”œβ”€β”€ bytes@0.2.1
β”‚ β”‚ β”œβ”€β”€ methods@0.0.1
β”‚ β”‚ β”œβ”€β”¬ multiparty@2.2.0
β”‚ β”‚ β”‚ β”œβ”€β”¬ readable-stream@1.1.9
β”‚ β”‚ β”‚ β”‚ β”œβ”€β”€ core-util-is@1.0.0
β”‚ β”‚ β”‚ β”‚ └── debuglog@0.0.2
β”‚ β”‚ β”‚ └── stream-counter@0.2.0
β”‚ β”‚ β”œβ”€β”€ negotiator@0.3.0
β”‚ β”‚ β”œβ”€β”€ pause@0.0.1
β”‚ β”‚ β”œβ”€β”€ qs@0.6.5
β”‚ β”‚ β”œβ”€β”€ raw-body@0.0.3
β”‚ β”‚ └── uid2@0.0.3
β”‚ β”œβ”€β”€ cookie@0.1.0
β”‚ β”œβ”€β”€ cookie-signature@1.0.1
β”‚ β”œβ”€β”€ debug@0.7.4
β”‚ β”œβ”€β”€ fresh@0.2.0
β”‚ β”œβ”€β”€ methods@0.1.0
β”‚ β”œβ”€β”€ mkdirp@0.3.5
β”‚ β”œβ”€β”€ range-parser@0.0.4
β”‚ └─┬ send@0.1.4
β”‚   └── mime@1.2.11
β”œβ”€β”¬ jade@1.0.0
β”‚ β”œβ”€β”€ character-parser@1.2.0
β”‚ β”œβ”€β”€ commander@2.0.0
β”‚ β”œβ”€β”¬ constantinople@1.0.2
β”‚ β”‚ └─┬ uglify-js@2.4.8
β”‚ β”‚   β”œβ”€β”€ async@0.2.9
β”‚ β”‚   β”œβ”€β”¬ optimist@0.3.7
β”‚ β”‚   β”‚ └── wordwrap@0.0.2
β”‚ β”‚   β”œβ”€β”¬ source-map@0.1.31
β”‚ β”‚   β”‚ └── amdefine@0.1.0
β”‚ β”‚   └── uglify-to-browserify@1.0.1
β”‚ β”œβ”€β”€ mkdirp@0.3.5
β”‚ β”œβ”€β”¬ monocle@1.1.50
β”‚ β”‚ └─┬ readdirp@0.2.5
β”‚ β”‚   └─┬ minimatch@0.2.14
β”‚ β”‚     β”œβ”€β”€ lru-cache@2.5.0
β”‚ β”‚     └── sigmund@1.0.0
β”‚ β”œβ”€β”¬ transformers@2.1.0
β”‚ β”‚ β”œβ”€β”¬ css@1.0.8
β”‚ β”‚ β”‚ β”œβ”€β”€ css-parse@1.0.4
β”‚ β”‚ β”‚ └── css-stringify@1.0.5
β”‚ β”‚ β”œβ”€β”¬ promise@2.0.0
β”‚ β”‚ β”‚ └── is-promise@1.0.0
β”‚ β”‚ └─┬ uglify-js@2.2.5
β”‚ β”‚   β”œβ”€β”¬ optimist@0.3.7
β”‚ β”‚   β”‚ └── wordwrap@0.0.2
β”‚ β”‚   └─┬ source-map@0.1.31
β”‚ β”‚     └── amdefine@0.1.0
β”‚ └─┬ with@2.0.0
β”‚   └─┬ uglify-js@2.4.0
β”‚     β”œβ”€β”€ async@0.2.9
β”‚     β”œβ”€β”¬ optimist@0.3.7
β”‚     β”‚ └── wordwrap@0.0.2
β”‚     β”œβ”€β”¬ source-map@0.1.31
β”‚     β”‚ └── amdefine@0.1.0
β”‚     └── uglify-to-browserify@1.0.1
β”œβ”€β”€ simple-recaptcha@0.0.3 extraneous
└─┬ stylus@0.41.3
  β”œβ”€β”€ cssom@0.2.5
  β”œβ”€β”€ debug@0.7.4
  β”œβ”€β”€ mkdirp@0.3.5
  └── sax@0.5.8

npm ERR! extraneous: ejs@0.8.5 /Users/juan.gallardo/Desktop/myfiles/test-projects/bruxzir-express-test/node_modules/ejs
npm ERR! extraneous: simple-recaptcha@0.0.3 /Users/juan.gallardo/Desktop/myfiles/test-projects/bruxzir-express-test/node_modules/simple-recaptcha
npm ERR! not ok code 0
+4
source share
1 answer

I solved this by simply listing the EJS and its version in mine package.json.

"ejs": "0.8.5"    

EJS, , , , npm list.

, , .

{
  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app.js"
  },
  "dependencies": {
    "express": "3.4.4",
    "jade": "*",
    "stylus": "*",
    "ejs": "0.8.5"
  },
  "engines": {
    "node": "0.10.1",
    "npm": "1.3.14"
  }
}
+5

All Articles