错误:找不到模块'./Mime'

时间:2018-01-03 16:05:57

标签: node.js heroku

我正在尝试运行一个heroku项目(遵循教程here)并且我遇到了一些麻烦。

Heroku上的节点任务正在抛出以下内容:

app[web.1]:     module.js:540
app[web.1]:     throw err;
app[web.1]:     ^
app[web.1]:
app[web.1]: Error: Cannot find module './Mime'
app[web.1]:     at Function.Module._resolveFilename (module.js:538:15)
app[web.1]:     at Function.Module._load (module.js:468:25)
app[web.1]:     at Module.require (module.js:587:17)
app[web.1]:     at Object.<anonymous> (/app/node_modules/mime/index.js:3:12)
app[web.1]:     at require (internal/module.js:11:18)
app[web.1]:     at Module._compile (module.js:643:30)
app[web.1]:     at Object.Module._extensions..js (module.js:654:10)
app[web.1]:     at Module.load (module.js:556:32)
app[web.1]:     at tryModuleLoad (module.js:499:12)
app[web.1]:     at Function.Module._load (module.js:491:3)

我已经安装了(使用-save)我需要的所有依赖项,包括mime,但似乎它已经赶上了mime模块本身,这里是mime node_module:

         1,545 .eslintrc.json
<DIR>          .github
         9,230 CHANGELOG.md
           157 cli.js
           127 index.js
         1,098 LICENSE
           101 lite.js
         1,951 Mime.js
         2,824 package.json
         5,468 README.md
<DIR>          src
<DIR>          types

mime / index.js文件:

'use strict';

var Mime = require('./Mime');
module.exports = new Mime(require('./types/standard'), require('./types/other'));

和我的项目的依赖项

"dependencies": {
    "body-parser": "^1.15.2",
    "cheerio": "^1.0.0-rc.2",
    "cookie-parser": "^1.4.3",
    "express": "^4.14.0",
    "express-handlebars": "^3.0.0",
    "express-less": "^0.1.0",
    "express-minify": "^0.2.0",
    "favicon": "0.0.2",
    "helmet": "^2.3.0",
    "http": "0.0.0",
    "logger": "0.0.1",
    "mime": "^2.0.3",
    "mongodb": "^2.2.11",
    "morgan": "^1.7.0",
    "nodemailer": "^4.4.1",
    "nodemailer-sendgrid-transport": "^0.2.0",
    "path": "^0.12.7",
    "serve-favicon": "^2.3.0"
  }

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

Whelp,我很难说100%解决了这个问题,但这可能是以下事情之一。

  • 我将pdf添加到我的节点包(请参阅here
  • 我使用"engines": {"node": "7.5.0","npm": "4.1.2"}(见here
  • 向根添加了一个Procfile

作为旁注,在我解决了这个问题后,缓存对我来说是个大问题。 This链接可能有助于此。

相关问题