无法在Heroku中查看Express/React应用(当前未找到) [英] Can't View Express/React App in Heroku (concurrently not found)
问题描述
我无法在Heroku中查看我的Node/Express + React项目.将项目成功推送到Heroku后,尝试在Heroku中查看我的应用程序时出现404错误页面.
I'm having trouble viewing my Node/Express + React project in Heroku. After successfully pushing my project to Heroku, I get a 404 error page when I try to view my app in heroku.
Heroku日志显示未找到concurrently
程序包
Heroku Logs shows that the concurrently
package was not found
我想知道是否有人可以帮助我找出原因? 一切都在本地工作.没有问题. 我还没有找到任何解决方案.我已经试过了: https://github.com/RickWong/react-isomorphic-starterkit/issues/12
I was wondering if anyone can help me figure out why? Everything works locally. No issues. I haven't been able to find any solutions. I've tried this: https://github.com/RickWong/react-isomorphic-starterkit/issues/12
我尝试通过以下建议在heroku中设置环境变量:
I tried setting an environment variable in heroku with the following suggestion:
heroku config:set NPM_CONFIG_PRODUCTION=false
但是,它没有用.
我也发现了这一点
https://github.com/rickbergfalk/sqlpad/issues/359
我尝试在服务器文件夹以及根目录中重新安装concurrently
两次.但是对于每个实例,我都会遇到相同的错误,告诉我未找到concurrently
.
I've attempted re-installing concurrently
twice, in the server folder, as well as in root. But with each instance, I got the same error telling me that concurrently
was not found.
以下是Heroku日志:
Here is the Heroku log:
2019-01-05T04:44:42.843348+00:00 heroku[web.1]: Starting process with command `npm start`
2019-01-05T04:44:45.795355+00:00 heroku[web.1]: Process exited with status 1
2019-01-05T04:44:45.817371+00:00 heroku[web.1]: State changed from starting to crashed
2019-01-05T04:44:45.825275+00:00 heroku[web.1]: State changed from crashed to starting
2019-01-05T04:44:45.691080+00:00 app[web.1]:
2019-01-05T04:44:45.691107+00:00 app[web.1]: > hello_fullstack@1.0.0 start /app
2019-01-05T04:44:45.691110+00:00 app[web.1]: > concurrently -- kill-others "npm run server" "npm run client"
2019-01-05T04:44:45.691112+00:00 app[web.1]:
2019-01-05T04:44:45.699841+00:00 app[web.1]: sh: 1: concurrently: not found
2019-01-05T04:44:45.704281+00:00 app[web.1]: npm ERR! file sh
2019-01-05T04:44:45.704664+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-01-05T04:44:45.704985+00:00 app[web.1]: npm ERR! errno ENOENT
2019-01-05T04:44:45.705300+00:00 app[web.1]: npm ERR! syscall spawn
2019-01-05T04:44:45.706913+00:00 app[web.1]: npm ERR! hello_fullstack@1.0.0 start: `concurrently -- kill-others "npm run server" "npm run client"`
2019-01-05T04:44:45.707140+00:00 app[web.1]: npm ERR! spawn ENOENT
2019-01-05T04:44:45.707475+00:00 app[web.1]: npm ERR!
2019-01-05T04:44:45.707708+00:00 app[web.1]: npm ERR! Failed at the hello_fullstack@1.0.0 start script.
2019-01-05T04:44:45.708000+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-01-05T04:44:45.718125+00:00 app[web.1]:
2019-01-05T04:44:45.718481+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-01-05T04:44:45.718674+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-01-05T04_44_45_709Z-debug.log
有什么建议吗?
(不确定这很重要,但是我的开发环境在ubuntu中,我正在virtualbox中运行;主机操作系统是Windows 8)
(Not sure this matters, but my dev environment is in ubuntu, which I'm running inside virtualbox; host os is Windows 8)
推荐答案
我找到了解决问题的方法.
I found a solution to my problem.
在苦苦挣扎之后,我决定重新开始并构建一个示例react/express应用程序,看看是否可以将其部署到heroku.成功部署后,我将示例应用程序和损坏的应用程序中的代码进行了比较.然后我想到,问题可能出在我分配给根文件夹的package.json文件中的heroku-postbuild
脚本的命令上.
After struggling with it, I decided to just start over and build a sample react/express app, and see if I could deploy it to heroku. Upon successfully deploying, I compared the code from my sample app and my broken app. It then occurred to me that perhaps the issue was with the commands that I assigned to the heroku-postbuild
script in the package.json file of my root folder.
以前,我有这个垃圾:
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
我将其更改为:
"heroku-postbuild": "cd client && npm install && npm run build"
而且,就像魔术一样,它起作用了!我想我不是在构建"我应该在heroku方面构建的东西.
And, like magic, it worked! I guess I wasn't "building" what I was supposed to build on the heroku side.
这篇关于无法在Heroku中查看Express/React应用(当前未找到)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!