错误:部署到Heroku时找不到模块

时间:2018-02-08 02:59:00

标签: node.js heroku deployment procfile

我有一个具有以下结构的项目:

root_folder
- package.json
- server
-- index.js
- signalmaster
-- server.js

我正在尝试部署应用程序并使用Procfile启动2个节点服务器:

web: node server/index.js
webrtc: node signalmaster/server.js

如果我运行,可以在本地不同的标签中启动2台服务器:

node server/index.js
node signalmaster/server.js

但是当我将它部署到Heroku时,我收到以下错误:

Starting process with command `node signalmaster/server.js`
2018-02-08T02:45:52.143212+00:00 heroku[web.1]: State changed from starting to up
2018-02-08T02:45:52.450671+00:00 heroku[webrtc.1]: State changed from starting to up
2018-02-08T02:45:53.864411+00:00 heroku[webrtc.1]: State changed from up to crashed
2018-02-08T02:45:53.850099+00:00 heroku[webrtc.1]: Process exited with status 1
2018-02-08T02:45:53.776642+00:00 app[webrtc.1]: module.js:540
2018-02-08T02:45:53.776677+00:00 app[webrtc.1]:
2018-02-08T02:45:53.776673+00:00 app[webrtc.1]:     throw err;
2018-02-08T02:45:53.776676+00:00 app[webrtc.1]:     ^
2018-02-08T02:45:53.776679+00:00 app[webrtc.1]: Error: Cannot find module '/app/signalmaster/server.js'
2018-02-08T02:45:53.776681+00:00 app[webrtc.1]:     at Function.Module._resolveFilename (module.js:538:15)
2018-02-08T02:45:53.776683+00:00 app[webrtc.1]:     at Function.Module._load (module.js:468:25)
2018-02-08T02:45:53.776685+00:00 app[webrtc.1]:     at Function.Module.runMain (module.js:684:10)
2018-02-08T02:45:53.776686+00:00 app[webrtc.1]:     at startup (bootstrap_node.js:187:16)
2018-02-08T02:45:53.776689+00:00 app[webrtc.1]:     at bootstrap_node.js:608:3

我的启动脚本如下所示:

"build:production": "NODE_ENV=production webpack --config webpack.config.js",
"start": "node server/index.js",
"postinstall": "npm run build:production"

0 个答案:

没有答案