简体   繁体   中英

Node deployment to heroku fails

I am trying to deploy a basic app to heroku and i am getting an error. I have included heroku log.

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

By default, Heroku looks into the Profice first in order to start server. And only then it looks into package.json's start script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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