【问题标题】:Error with mongodb driver on Heroku: Cannot find module 'mongodb-core'Heroku 上的 mongodb 驱动程序出错:找不到模块 'mongodb-core'
【发布时间】:2015-10-23 13:36:01
【问题描述】:

我正在尝试将我的 Node.js Express 应用程序升级到更新的 Mongodb 驱动程序。我的 package.json 有“mongodb”:“^2.0.40”。它在我的机器上运行良好,我可以很好地部署到 Heroku(如,没有警告/错误)。但是,应用程序在使用时崩溃,并出现以下错误:

2015-09-14T13:03:52.225525+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-09-14T13:03:52.271972+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-14T13:03:54.315461+00:00 heroku[web.1]: Process exited with status 143
2015-09-14T13:03:54.701499+00:00 app[web.1]: module.js:338
2015-09-14T13:03:54.701522+00:00 app[web.1]:     throw err;
2015-09-14T13:03:54.701523+00:00 app[web.1]:           ^
2015-09-14T13:03:54.701525+00:00 app[web.1]: Error: Cannot find module 'mongodb-core'
2015-09-14T13:03:54.701526+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:336:15)
2015-09-14T13:03:54.701527+00:00 app[web.1]:     at Function.Module._load (module.js:278:25)
2015-09-14T13:03:54.701529+00:00 app[web.1]:     at require (module.js:384:17)
2015-09-14T13:03:54.701528+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-09-14T13:03:54.701531+00:00 app[web.1]:     at Object.<anonymous> (/app/node_modules/mongodb/index.js:2:12)
2015-09-14T13:03:54.701532+00:00 app[web.1]:     at Module._compile (module.js:460:26)
2015-09-14T13:03:54.701533+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:478:10)
2015-09-14T13:03:54.701534+00:00 app[web.1]:     at Module.load (module.js:355:32)
2015-09-14T13:03:54.701535+00:00 app[web.1]:     at Function.Module._load (module.js:310:12)
2015-09-14T13:03:54.701536+00:00 app[web.1]:     at Module.require (module.js:365:17)
2015-09-14T13:03:55.561071+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-14T13:03:55.548974+00:00 heroku[web.1]: Process exited with status 1

我尝试了各种版本的mongodb驱动,都无济于事。

【问题讨论】:

  • 您介意填充 package.json “依赖项”部分吗?和“远程:----->构建成功!”从输出?..

标签: node.js mongodb heroku


【解决方案1】:

如果你使用 mongodb-core,你应该像这里一样在 package.json 中指定它:

   "dependencies": {
    "express": "~4.9.x"
    , "pg": "~4.4.x"
    , "mongodb": "2.0.14"
    , "mongodb-core": "~1.0"
  },

推送到git后,查看日志:

remote: -----> Build succeeded!
remote:        ├── express@4.9.8
remote:        ├── mongodb@2.0.14
remote:        ├── mongodb-core@1.0.5
remote:        └── pg@4.4.1

【讨论】:

    猜你喜欢
    • 2016-09-05
    • 1970-01-01
    • 2017-03-02
    • 2016-01-20
    • 2023-03-10
    • 2023-03-20
    • 2016-03-13
    • 2014-04-11
    • 2022-08-05
    相关资源
    最近更新 更多