简体   繁体   English

无法在Heroku中查看Express / React应用(当前未找到)

[英]Can't View Express/React App in Heroku (concurrently not found)

I'm having trouble viewing my Node/Express + React project in Heroku. 我在查看Heroku中的Node / Express + React项目时遇到问题。 After successfully pushing my project to Heroku, I get a 404 error page when I try to view my app in heroku. 将项目成功推送到Heroku后,尝试在Heroku中查看我的应用程序时出现404错误页面。

Heroku Logs shows that the concurrently package was not found Heroku Logs显示未找到concurrently发包

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 我试过了: https : //github.com/RickWong/react-isomorphic-starterkit/issues/12

I tried setting an environment variable in heroku with the following suggestion: 我尝试使用以下建议在heroku中设置环境变量:

heroku config:set NPM_CONFIG_PRODUCTION=false

However, it did not work. 但是,它没有用。

I also found this: 我也发现了这一点:

https://github.com/rickbergfalk/sqlpad/issues/359 https://github.com/rickbergfalk/sqlpad/issues/359

I've attempted re-installing concurrently twice, in the server folder, as well as in root. 我试图concurrently在服务器文件夹和根目录中重新安装两次。 But with each instance, I got the same error telling me that concurrently was not found. 但是,每个实例,我得到了同样的错误,告诉我, concurrently没有被发现。

Here is the Heroku log: 这是Heroku日志:

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

Any suggestions? 有什么建议么?

(Not sure this matters, but my dev environment is in ubuntu, which I'm running inside virtualbox; host os is Windows 8) (不确定这很重要,但是我的开发环境在ubuntu中,我在virtualbox中运行;主机os是Windows 8)

I found a solution to my problem. 我找到了解决问题的方法。

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. 在苦苦挣扎之后,我决定重新开始并构建一个示例react / express应用程序,看看是否可以将其部署到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. 然后我想到,问题可能出在我分配给根文件夹的package.json文件中的heroku-postbuild脚本的命令上。

Previously, I had this junk: 以前,我有这个垃圾:

"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"

I changed that to this: 我将其更改为:

"heroku-postbuild": "cd client && npm install && npm run build"

And, like magic, it worked! 而且,就像魔术一样,它起作用了! I guess I wasn't "building" what I was supposed to build on the heroku side. 我想我不是在“构建”我应该在heroku方面构建的东西。

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

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