[英]Heroku Cannot Find Module (Model File)
部署到Heroku
时,我的Node.js
应用程序中出现模型导入错误。
2016-02-10T20:40:04.712617+00:00 app[web.1]: > node ./bin/www
2016-02-10T20:40:04.712615+00:00 app[web.1]: > comic@0.0.0 start /app
2016-02-10T20:40:05.770633+00:00 app[web.1]: throw err;
2016-02-10T20:40:05.770629+00:00 app[web.1]: module.js:341
2016-02-10T20:40:05.770637+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-02-10T20:40:05.770636+00:00 app[web.1]: Error: Cannot find module '../models/Comic'
2016-02-10T20:40:05.770638+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-02-10T20:40:05.770634+00:00 app[web.1]: ^
2016-02-10T20:40:05.770640+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-02-10T20:40:05.770641+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-02-10T20:40:05.770639+00:00 app[web.1]: at require (internal/module.js:16:19)
2016-02-10T20:40:05.770642+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-02-10T20:40:05.770637+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-02-10T20:40:05.770640+00:00 app[web.1]: at Object.<anonymous> (/app/routes/create.js:2:13)
2016-02-10T20:40:05.770643+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-02-10T20:40:05.770642+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-02-10T20:40:05.804819+00:00 app[web.1]:
我已经尝试在app
node
会话中进行heroku run bash
并运行require('./models/Comic')
并从/app/routes/
的子目录中运行require('../models/Comic')
以测试require
作品。
Comic
require
的唯一实例位于routes
文件夹中的三个路由中。 它们都具有完全相同的var myVar = require('../models/Comic');
。
我发现heroku
:
a)从Git获取信息。 即使我在本地文件中进行了大小写更改并将其推送到Git,大小写也没有改变。 然后,在使用Linux的heroku
上需要该文件时,它找不到该文件。
b)仅从heroku run bash
更改文件名似乎没有任何影响。 我以为我没有做某种部署步骤,或者我需要做一些额外的事情(我尝试过heroku restart
但没有骰子)。
希望这可以帮助其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.