在Heroku上找不到模块'ejs'-Node.js应用 [英] Cannot find module 'ejs' - Node.js app on Heroku

查看:71
本文介绍了在Heroku上找不到模块'ejs'-Node.js应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在本地运行,但是当我部署到Heroku时出现问题。这是我的错误,似乎该错误是由添加EJS后无法执行的操作引起的。

My app was working locally but when I deployed to Heroku, there was an issue. This was my error, It seems that the error was caused by something that I failed to do after I added 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=

阅读此问题后n SO 我需要在 package.json 中添加该依赖项。对于ejs的版本,我运行了 npm list 并得到了它,看来可能还有更多错误要解决。

After reading this question on SO I needed to add that dependency in the package.json . And to the version of ejs I ran npm list and got this, which looks like there might be more errors to address.

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


推荐答案

我只是通过列出EJS来解决此问题并将其版本添加到我的 package.json 中。

I resolved this just by listing EJS and its version into my package.json .

"ejs": "0.8.5"    

如果您不知道所拥有的EJS版本,我发现我的方法是运行 npm list

If you do not know the version of EJS that you have, the way I found mine was to run npm list.

这是我当前的整个文件,如果您很好奇它们如何组合在一起以在heroku上进行部署。

Here is my current entire file if you are curious how it all fits in together to deploy on heroku.

{
  "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"
  }
}

这篇关于在Heroku上找不到模块'ejs'-Node.js应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆