我用heroku部署了nodejs应用,尝试在浏览器中打开它时出现错误
所以我已经用启动脚本检查了我的package.json,并且已经设置了节点环境和生产,我检查了模型(错误之一指向日志中的错误),我不确定它是什么
2019-07-09T02:50:24.457773+00:00 heroku[web.1]: State changed from starting to crashed
2019-07-09T02:50:24.385238+00:00 app[web.1]: internal/modules/cjs/loader.js:613
2019-07-09T02:50:24.385263+00:00 app[web.1]: throw err;
2019-07-09T02:50:24.385266+00:00 app[web.1]: ^
2019-07-09T02:50:24.385267+00:00 app[web.1]:
2019-07-09T02:50:24.385270+00:00 app[web.1]: Error: Cannot find module '../models/user'
2019-07-09T02:50:24.385272+00:00 app[web.1]: Require stack:
2019-07-09T02:50:24.385274+00:00 app[web.1]: - /app/routes/index.js
2019-07-09T02:50:24.385276+00:00 app[web.1]: - /app/app.js
2019-07-09T02:50:24.385279+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:610:15)
2019-07-09T02:50:24.385281+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:526:27)
2019-07-09T02:50:24.385368+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:666:19)
2019-07-09T02:50:24.385373+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:16:16)
2019-07-09T02:50:24.385375+00:00 app[web.1]: at Object.<anonymous> (/app/routes/index.js:3:14)
2019-07-09T02:50:24.385377+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:759:30)
2019-07-09T02:50:24.385379+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
2019-07-09T02:50:24.385381+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:628:32)
2019-07-09T02:50:24.385383+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:555:12)
2019-07-09T02:50:24.385385+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:666:19)
2019-07-09T02:50:24.438626+00:00 heroku[web.1]: Process exited with status 1
链接到github仓库 https://github.com/ArielBailon/b--learning
答案 0 :(得分:0)
您致电:
require('../models/user')
但是您的文件是User.js
您可以选择:
User.js
重命名为user.js
require('../models/User')
代替require('../models/user')