[英]Heroku Cannot Find Module (Model File)
I am getting a model import error in my Node.js
application when deploying to Heroku
. 部署到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]:
I have tried doing heroku run bash
and running require('./models/Comic')
from node
session in app
and require('../models/Comic')
from within a subdirectory of /app/routes/
to test that require
works. 我已经尝试在app
node
会话中进行heroku run bash
并运行require('./models/Comic')
并从/app/routes/
的子目录中运行require('../models/Comic')
以测试require
作品。
The only instances of the require
for Comic
are in the three routes within the routes
folder. Comic
require
的唯一实例位于routes
文件夹中的三个路由中。 They all have the exact same var myVar = require('../models/Comic');
它们都具有完全相同的var myVar = require('../models/Comic');
. 。
I figured out that heroku
: 我发现heroku
:
a) Takes the info from Git. a)从Git获取信息。 Even though I had made case changes in my local files and pushed to Git, the case wasn't changed. 即使我在本地文件中进行了大小写更改并将其推送到Git,大小写也没有改变。 Then when the file was required on heroku
which uses Linux, it could not find the file. 然后,在使用Linux的heroku
上需要该文件时,它找不到该文件。
b) Only changing the name of the file from heroku run bash
didn't seem to have any affect. b)仅从heroku run bash
更改文件名似乎没有任何影响。 I am assuming I wasn't doing some sort of deployment step or that I needed to do something extra (I tried heroku restart
but no dice). 我以为我没有做某种部署步骤,或者我需要做一些额外的事情(我尝试过heroku restart
但没有骰子)。
Hope this can help someone else. 希望这可以帮助其他人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.