节点部署到 heroku 失败



我正在尝试将基本应用程序部署到heroku,但遇到错误。我已经包括了英雄日志。

2018-08-12T11:19:35.082630+00:00 app[web.1]: Error: Cannot find module '/app/server/server.js'
2018-08-12T11:19:35.082632+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2018-08-12T11:19:35.082634+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2018-08-12T11:19:35.082635+00:00 app[web.1]: at Function.Module.runMain (module.js:676:10)
2018-08-12T11:19:35.082651+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-08-12T11:19:35.082653+00:00 app[web.1]: at bootstrap_node.js:608:3
2018-08-12T11:19:35.165790+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-12T11:19:35.168329+00:00 heroku[web.1]: State changed from crashed to starting
2018-08-12T11:19:38.372891+00:00 heroku[web.1]: Starting process with command `node server/server.js`
2018-08-12T11:19:40.669347+00:00 heroku[web.1]: Process exited with status 1
2018-08-12T11:19:40.685006+00:00 heroku[web.1]: State changed from starting to crashed
2018-08-12T11:19:40.573913+00:00 app[web.1]: module.js:538
2018-08-12T11:19:40.573936+00:00 app[web.1]: throw err;
2018-08-12T11:19:40.573938+00:00 app[web.1]: ^
2018-08-12T11:19:40.573940+00:00 app[web.1]:
2018-08-12T11:19:40.573942+00:00 app[web.1]: Error: Cannot find module '/app/server/server.js'
2018-08-12T11:19:40.573943+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2018-08-12T11:19:40.573945+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2018-08-12T11:19:40.573947+00:00 app[web.1]: at Function.Module.runMain (module.js:676:10)
2018-08-12T11:19:40.573949+00:00 app[web.1]: at startup (bootstrap_node.js:187:16)
2018-08-12T11:19:40.573951+00:00 app[web.1]: at bootstrap_node.js:608:3

我已经包含了这样的启动脚本

"scripts": {
"start": "node server/server.js",
"test": "export NODE_ENV=test || SET "NODE_ENV=test" && mocha "./{,!(node_modules)/**/}*.test.js""
},

请告诉我我错过了什么。我还附加了我的根目录文件夹image.image

一旦你已经在使用 Procfile,你可以在那里指定:web: node server/server.js

默认情况下,Heroku 首先查看 Profice 以启动服务器。然后它才会查看 package.json 的启动脚本。

最新更新