[英]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.