【发布时间】:2015-07-13 06:15:27
【问题描述】:
因此,当尝试将 Node.js 应用程序部署到 Heroku 时,使用 heroku logs -t 时出现此错误。
> State changed from crashed to starting Starting process with command
> `node ./bin/www` Detected 512 MB available memory, 512 MB limit per
> process (WEB_MEMORY) Recommending WEB_CONCURRENCY=1 Error: Cannot
> find module 'mongodb/lib/read_preference'
> throw err; module.js:340
> ^
> at Function.Module._resolveFilename (module.js:338:15)
> at Function.Module._load (module.js:280:25)
> at Module.require (module.js:364:17)
> at require (module.js:380:17)
> at Module._compile (module.js:456:26)
> at Object.Module._extensions..js (module.js:474:10)
> at Object.<anonymous> (/app/node_modules/mongoose/lib/utils.js:5:16)
> at Module.load (module.js:356:32)
> at Function.Module._load (module.js:312:12)
> at Module.require (module.js:364:17)
寻找目标文件的文件的文件夹结构是这样的(在node_modules文件夹里面):
mongoose/lib/utils.js
查找文件的代码是这样的:
var ReadPref = require('mongodb/lib/read_preference')
目标文件位于:
mongoose/node_modules/mongodb/lib/read_preference.js
现在基于Node的搜索算法(https://nodejs.org/api/modules.html),文件会向上移动到node_modules文件夹,然后搜索mongodb,找到它并进入它的文件夹,最后到达read_preference文件。然而,这显然是行不通的。我该怎么做才能解决这个问题?
【问题讨论】:
标签: node.js heroku mongoose npm