【问题标题】:Mongo error when loading on mobile在移动设备上加载时出现 Mongo 错误
【发布时间】:2016-02-29 00:00:12
【问题描述】:

在手机上加载我的测试 MEAN 应用时,我在 mongo 上收到以下错误。

我不知道是哪个模块,因为我没有自己加载它。

奇怪的是,在桌面浏览器上,错误不会弹出。

我正在使用 mongoose 作为 mongodb 驱动程序。可能错误与它有关。

有什么见解吗?

Error: Cannot find module '../schemas/favicon.icSchema'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at modelNamer (/home/rafapaulin/lab/rpg-am/routes/general.js:13:10)
    at /home/rafapaulin/lab/rpg-am/routes/general.js:19:3
    at Layer.handle [as handle_request] (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/layer.js:95:5)
    at /home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:277:22
    at param (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:349:14)
    at param (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:365:14)
    at Function.process_params (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:410:3)
    at next (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:271:10)
    at Function.handle (/home/rafapaulin/lab/rpg-am/node_modules/express/lib/router/index.js:176:3)

【问题讨论】:

  • 你能分享一下代码吗:/home/rafapaulin/lab/rpg-am/routes/general.js:13:10。这可能会有所帮助。
  • sure @unflores var modelNamer = function(collection){ return require('../schemas/' + collection.slice(0, -1) + 'Schema') }; 基本上,这个函数建立模型的名称,基于通过的路线。它在桌面上运行,实际上,它也适用于移动设备上的 POST 请求......当页面在移动设备上加载时会弹出该错误,但路由仍然有效

标签: angularjs node.js mongodb mobile mongoose


【解决方案1】:

好的,所以我认为您的路径可能会发生一些神奇的事情。从桌面和移动设备调用时,您可以尝试记录当前路径。

或者您可以尝试以下操作:absolute requires,这将确保您需要具有来自 server.js 目录的绝对路径的内容。

【讨论】:

    猜你喜欢
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    相关资源
    最近更新 更多