Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Heroku上的React应用程序部署:npm包安装后加载暂停_Node.js_Reactjs_Express_Heroku - Fatal编程技术网

Node.js Heroku上的React应用程序部署:npm包安装后加载暂停

Node.js Heroku上的React应用程序部署:npm包安装后加载暂停,node.js,reactjs,express,heroku,Node.js,Reactjs,Express,Heroku,我有一个使用Express后端和React前端的web应用程序。我的package.json中的heroku postbuild脚本如下: "heroku-postbuild": "concurrently \"node server.js\" \"cd client && npm install && npm run build\"" 当Igit push heroku master时,一切似乎都正常,直到进程在以下位置停止: remote: [

我有一个使用Express后端和React前端的web应用程序。我的
package.json
中的
heroku postbuild
脚本如下:

"heroku-postbuild": "concurrently \"node server.js\" \"cd client && npm install && npm run build\""
当I
git push heroku master
时,一切似乎都正常,直到进程在以下位置停止:

remote:        [1] cd client && npm install && npm run build exited with code 0

在我
ctrl
+
c
终止之前,它已经处于这种状态大约30分钟了。你知道为什么会发生这种情况吗?

希望这会对你有所帮助,因为我试过了,而且效果很好

"scripts": {
    "start": "node server.js",
    "server": "nodemon server.js",
    "client": "npm start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\"",
    "heroku-postbuild": "npm install --prefix client        && npm run build --prefix client"  
  }

有关更多详细信息,请参见。

我按照@iamWebKalakar的建议解决了这个问题:

"heroku-postbuild": "cd client && npm install && npm run build"
此外,将my
Procfile
中的开始脚本设置为:

web: npm run server
它引用了我的
包.json中的脚本:

server: "node server.js"
我的建议是,
heroku postbuild
应该包含与React(包安装和构建)相关的任何内容,
Procfile
脚本应该运行express服务器