简体   繁体   English

部署后如何解决 heroku 中未找到的错误

[英]How to solve not found error in heroku after deployment

I'm tried to upload a MERN stack project on heroku , when I push my project then does not show me any error, but after that when I tried to open my app then show me error like this:我试图在 heroku 上上传heroku堆栈项目,当我推送我的项目时没有显示任何错误,但之后当我尝试打开我的应用程序时显示如下错误:

在此处输入图像描述

Then when I see on heroku logs show me error like this:然后,当我在heroku logs上看到时,会显示如下错误:

2021-04-02T04:39:53.640765+00:00 app[web.1]: }
2021-04-02T04:39:53.673306+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-04-02T04:39:53.673901+00:00 app[web.1]: npm ERR! errno 1
2021-04-02T04:39:53.688128+00:00 app[web.1]: npm ERR! react-boiler-plate@1.0.0 start: `node server/index.js`
2021-04-02T04:39:53.688366+00:00 app[web.1]: npm ERR! Exit status 1
2021-04-02T04:39:53.688645+00:00 app[web.1]: npm ERR!
2021-04-02T04:39:53.688864+00:00 app[web.1]: npm ERR! Failed at the react-boiler-plate@1.0.0 start script.
2021-04-02T04:39:53.689072+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-04-02T04:39:53.702373+00:00 app[web.1]: 
2021-04-02T04:39:53.702750+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-04-02T04:39:53.702956+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2021-04-02T04_39_53_691Z-debug.log
2021-04-02T04:39:53.801523+00:00 heroku[web.1]: Process exited with status 1
2021-04-02T04:39:57.606025+00:00 app[web.1]: 
2021-04-02T04:39:57.606043+00:00 app[web.1]: > react-boiler-plate@1.0.0 start /app
2021-04-02T04:39:57.606044+00:00 app[web.1]: > node server/index.js
2021-04-02T04:39:57.606044+00:00 app[web.1]:
2021-04-02T04:39:59.617643+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2021-04-02T04:39:59.617704+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-04-02T04:39:59.618588+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency        
2021-04-02T04:39:59.618717+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2021-04-02T04:39:59.618853+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency      
2021-04-02T04:39:59.619452+00:00 app[web.1]: Server Listening on 52400
2021-04-02T04:39:59.664202+00:00 heroku[web.1]: State changed from starting to up
2021-04-02T04:40:00.154607+00:00 app[web.1]: MongoDB Connected...
2021-04-02T04:40:02.562719+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=482fc0ad-4dbf-4d68-a0b8-4ad915f0356d fwd="116.58.200.211" dyno=web.1 connect=0ms service=81ms status=404 bytes=412 protocol=https
2021-04-02T04:40:02.564414+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:40:12.580732+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=0cb0a90a-eefe-4730-97f2-58ad7601fb31 fwd="116.58.200.211" dyno=web.1 connect=0ms service=11ms status=404 bytes=412 protocol=https
2021-04-02T04:40:12.581974+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:41:07.703010+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=5195792b-17a0-4044-82a6-8e392f3bc920 fwd="116.58.200.211" dyno=web.1 connect=0ms service=13ms status=404 bytes=412 protocol=https
2021-04-02T04:41:07.703565+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:43:56.612829+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:43:56.614507+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=24d996e4-a43f-427c-89d5-a83fad29ec8e fwd="116.58.200.211" dyno=web.1 connect=2ms service=15ms status=404 bytes=412 protocol=https
2021-04-02T04:47:24.095734+00:00 app[api]: Set NODE_ENV config vars by user alaminsheikh30025@gmail.com
2021-04-02T04:47:24.095734+00:00 app[api]: Release v7 created by user alaminsheikh30025@gmail.com
2021-04-02T04:47:24.300332+00:00 heroku[web.1]: Restarting
2021-04-02T04:47:24.302570+00:00 heroku[web.1]: State changed from up to starting
2021-04-02T04:47:26.081387+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-04-02T04:47:26.273408+00:00 heroku[web.1]: Process exited with status 143
2021-04-02T04:47:28.480334+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-02T04:47:32.050957+00:00 app[web.1]:
2021-04-02T04:47:32.050999+00:00 app[web.1]: > react-boiler-plate@1.0.0 start /app
2021-04-02T04:47:32.051000+00:00 app[web.1]: > node server/index.js
2021-04-02T04:47:32.051001+00:00 app[web.1]:
2021-04-02T04:47:33.084385+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2021-04-02T04:47:33.084397+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-04-02T04:47:33.085117+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency        
2021-04-02T04:47:33.085232+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2021-04-02T04:47:33.085334+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency      
2021-04-02T04:47:33.085964+00:00 app[web.1]: Server Listening on 8465
2021-04-02T04:47:33.331113+00:00 app[web.1]: MongoDB Connected...
2021-04-02T04:47:33.388190+00:00 heroku[web.1]: State changed from starting to up
2021-04-02T04:47:34.346673+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=183fcfe3-db55-4a00-b385-9d7d66f60ed4 fwd="116.58.200.211" dyno=web.1 connect=1ms service=24ms status=404 bytes=412 protocol=https
2021-04-02T04:47:34.348398+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:48:45.968962+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=2a1df37e-9697-4cf4-be41-cc907f6cb724 fwd="116.58.200.211" dyno=web.1 connect=0ms service=16ms status=404 bytes=412 protocol=https
2021-04-02T04:48:45.969496+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:55:29.405371+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T04:55:29.405889+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=b9b8b037-8c4a-4c58-9fc9-d116af2283e9 fwd="116.58.200.211" dyno=web.1 connect=0ms service=10ms status=404 bytes=412 protocol=https
2021-04-02T05:02:01.000000+00:00 app[api]: Build started by user alaminsheikh30025@gmail.com
2021-04-02T05:02:35.128829+00:00 app[api]: Deploy 7dd2269f by user alaminsheikh30025@gmail.com
2021-04-02T05:02:35.128829+00:00 app[api]: Release v8 created by user alaminsheikh30025@gmail.com
2021-04-02T05:02:35.313075+00:00 heroku[web.1]: Restarting
2021-04-02T05:02:35.315983+00:00 heroku[web.1]: State changed from up to starting
2021-04-02T05:02:36.000000+00:00 app[api]: Build succeeded
2021-04-02T05:02:36.713360+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-04-02T05:02:36.983404+00:00 heroku[web.1]: Process exited with status 143
2021-04-02T05:02:39.085257+00:00 heroku[web.1]: Starting process with command `npm start`
2021-04-02T05:02:42.325482+00:00 app[web.1]:
2021-04-02T05:02:42.326048+00:00 app[web.1]: > react-boiler-plate@1.0.0 start /app
2021-04-02T05:02:42.326051+00:00 app[web.1]: > node server/index.js
2021-04-02T05:02:42.326053+00:00 app[web.1]:
2021-04-02T05:02:43.565518+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2021-04-02T05:02:43.565529+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-04-02T05:02:43.566549+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency        
2021-04-02T05:02:43.566660+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2021-04-02T05:02:43.566774+00:00 app[web.1]: (node:21) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency      
2021-04-02T05:02:43.567285+00:00 app[web.1]: Server Listening on 58335
2021-04-02T05:02:43.757613+00:00 app[web.1]: MongoDB Connected...
2021-04-02T05:02:43.923407+00:00 heroku[web.1]: State changed from starting to up
2021-04-02T05:03:06.224704+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=0dfe3e56-29e2-4abd-9326-30f22a3f3a3f fwd="116.58.200.211" dyno=web.1 connect=3ms service=24ms status=404 bytes=412 protocol=https
2021-04-02T05:03:06.226724+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'
2021-04-02T05:37:05.548583+00:00 heroku[web.1]: Idling
2021-04-02T05:37:05.550224+00:00 heroku[web.1]: State changed from up to down
2021-04-02T05:37:06.905027+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2021-04-02T05:37:07.188301+00:00 heroku[web.1]: Process exited with status 143
2021-04-02T05:45:52.000000+00:00 app[api]: Build started by user alaminsheikh30025@gmail.com
2021-04-02T05:46:24.941298+00:00 app[api]: Deploy 3d2e9eec by user alaminsheikh30025@gmail.com
2021-04-02T05:46:24.941298+00:00 app[api]: Release v9 created by user alaminsheikh30025@gmail.com
2021-04-02T05:46:25.895329+00:00 heroku[web.1]: State changed from down to starting
2021-04-02T05:46:26.000000+00:00 app[api]: Build succeeded
2021-04-02T05:46:29.859262+00:00 heroku[web.1]: Starting process with command `node index.js`
2021-04-02T05:46:33.688119+00:00 app[web.1]: (node:4) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2021-04-02T05:46:33.688136+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-04-02T05:46:33.688805+00:00 app[web.1]: (node:4) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
2021-04-02T05:46:33.688950+00:00 app[web.1]: (node:4) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2021-04-02T05:46:33.689117+00:00 app[web.1]: (node:4) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency       
2021-04-02T05:46:33.689750+00:00 app[web.1]: Server Listening on 3542
2021-04-02T05:46:33.946525+00:00 app[web.1]: MongoDB Connected...
2021-04-02T05:46:34.274995+00:00 heroku[web.1]: State changed from starting to up
2021-04-02T05:46:41.770270+00:00 heroku[router]: at=info method=GET path="/" host=portfolio-show.herokuapp.com request_id=c42834c5-a16c-4c12-ab34-41f2a229d0d6 fwd="116.58.200.211" dyno=web.1 connect=0ms service=48ms status=404 bytes=412 protocol=https
2021-04-02T05:46:41.775861+00:00 app[web.1]: Error: ENOENT: no such file or directory, stat '/app/client/build/index.html'

I have config file by this way:我通过这种方式有配置文件:

在此处输入图像描述

在此处输入图像描述

.dev.js file: .dev.js文件:

module.exports = {
  mongoURI:
    "mongodb+srv://username:pass@demo.erwyk.mongodb.net/PORTFOLIO?retryWrites=true&w=majority",
};

prod.js file: prod.js文件:

module.exports = {
  mongoURI: process.env.MONGO_URI,
};

key.js file: key.js文件:

if (process.env.NODE_ENV === 'production') {
    module.exports = require('./prod');
} else {
    module.exports = require('./dev');
}

then I have add config file on heroku:然后我在 heroku 上添加了配置文件:

在此处输入图像描述

Any Suggestion Please.请有任何建议。

Actually I was problem on project config, I have solved by this way:其实我是项目配置的问题,我已经通过这种方式解决了:

Make configuration for heroku deployment为 heroku 部署进行配置

specify npm and node version for frontend deployment.[check version npm -v and node -v ]为前端部署指定npmnode版本。[检查版本npm -vnode -v ]

Then npm run build for client folder然后npm run build

Put environment variable for production mode in heroku website [for me MONGO_URI ]将生产模式的环境变量放在 heroku 网站 [for me MONGO_URI ]

then go to server folder inside package.js然后 go 到package.js内的server文件夹

add this line of code添加这行代码

script {
....
"heroku-postbuild": "NPM_PRODUCTION:false npm install --prefix client && npm run build --prefix client"
}

That's it.而已。

then go to terminal...然后 go 到终端...

heroku login

git init

git add.

git commit -m "bug fixed"

heroku git:remote -a <app_name> (if already created a app in heroku, otherwise heroku create ) heroku git:remote -a <app_name> (如果已经在 heroku 中创建了应用程序,否则heroku create

git push heroku master

heroku open

Hope app will run successfully,希望应用程序能够成功运行,

Thank you, [if still faced any problem then let me know in the comment section]谢谢,[如果仍然遇到任何问题,请在评论部分告诉我]

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

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