简体   繁体   English

节点部署到heroku失败

[英]Node deployment to heroku fails

I am trying to deploy a basic app to heroku and i am getting an error. 我正在尝试将基本应用程序部署到heroku,但出现错误。 I have included heroku log. 我已经包括了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

I have included the start script like this 我已经包含了这样的启动脚本

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

please tell me what i am missing. 请告诉我我所缺少的。 I have also attached my root directory folders image. 我还附加了我的根目录文件夹图像。 image 图片

As soon as you are already using Procfile, you can specify there: web: node server/server.js 一旦您已经在使用Procfile,就可以在其中指定: web: node server/server.js

By default, Heroku looks into the Profice first in order to start server. 默认情况下,Heroku首先查看Profice以便启动服务器。 And only then it looks into package.json's start script. 然后,它才会查看package.json的启动脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM