Closed KoderKumar closed 3 years ago
all you got to do is literally point a express server to dist folder after compiling. start the express server and expose using the process.env.PORT https://www.freecodecamp.org/news/how-to-deploy-your-site-using-express-and-heroku/
I am deployed it n heroku and when i am opening the page it is giving me application error. So i ran heroku logs and it is giving me this error
2021-01-04T05:27:29.989034+00:00 app[api]: Release v1 created by user coderarth@gmail.com 2021-01-04T05:27:29.989034+00:00 app[api]: Initial release by user coderarth@gmail.com 2021-01-04T05:27:30.108960+00:00 app[api]: Release v2 created by user coderarth@gmail.com 2021-01-04T05:27:30.108960+00:00 app[api]: Enable Logplex by user coderarth@gmail.com 2021-01-04T05:27:52.000000+00:00 app[api]: Build started by user coderarth@gmail.com 2021-01-04T05:28:31.244807+00:00 app[api]: Deploy 59172bcd by user coderarth@gmail.com 2021-01-04T05:28:31.244807+00:00 app[api]: Release v3 created by user coderarth@gmail.com 2021-01-04T05:28:31.262503+00:00 app[api]: Scaled to web@1:Free by user coderarth@gmail.com 2021-01-04T05:28:35.000000+00:00 app[api]: Build succeeded 2021-01-04T05:28:36.431576+00:00 heroku[web.1]: Starting process with command
npm start 2021-01-04T05:28:40.767279+00:00 app[web.1]: 2021-01-04T05:28:40.767323+00:00 app[web.1]: > p2p.chat@0.2.8 start /app 2021-01-04T05:28:40.767329+00:00 app[web.1]: > webpack-dev-server --config webpack.config.js --port 3001 --hot --inline --history-api-fallback 2021-01-04T05:28:40.767330+00:00 app[web.1]: 2021-01-04T05:28:40.787117+00:00 app[web.1]: sh: 1: webpack-dev-server: not found 2021-01-04T05:28:40.815386+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-01-04T05:28:40.815882+00:00 app[web.1]: npm ERR! syscall spawn 2021-01-04T05:28:40.816230+00:00 app[web.1]: npm ERR! file sh 2021-01-04T05:28:40.816586+00:00 app[web.1]: npm ERR! errno ENOENT 2021-01-04T05:28:40.825873+00:00 app[web.1]: npm ERR! p2p.chat@0.2.8 start:
webpack-dev-server --config webpack.config.js --port 3001 --hot --inline --history-api-fallback 2021-01-04T05:28:40.826089+00:00 app[web.1]: npm ERR! spawn ENOENT 2021-01-04T05:28:40.826321+00:00 app[web.1]: npm ERR! 2021-01-04T05:28:40.826558+00:00 app[web.1]: npm ERR! Failed at the p2p.chat@0.2.8 start script. 2021-01-04T05:28:40.826758+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2021-01-04T05:28:40.837912+00:00 app[web.1]: 2021-01-04T05:28:40.844667+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2021-01-04T05:28:40.844872+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T05_28_40_828Z-debug.log 2021-01-04T05:28:40.923231+00:00 heroku[web.1]: Process exited with status 1 2021-01-04T05:28:40.977489+00:00 heroku[web.1]: State changed from starting to crashed 2021-01-04T05:28:40.981288+00:00 heroku[web.1]: State changed from crashed to starting 2021-01-04T05:28:45.201327+00:00 heroku[web.1]: Starting process with command
npm start 2021-01-04T05:28:48.342454+00:00 app[web.1]: 2021-01-04T05:28:48.342471+00:00 app[web.1]: > p2p.chat@0.2.8 start /app 2021-01-04T05:28:48.342488+00:00 app[web.1]: > webpack-dev-server --config webpack.config.js --port 3001 --hot --inline --history-api-fallback 2021-01-04T05:28:48.342489+00:00 app[web.1]: 2021-01-04T05:28:48.350447+00:00 app[web.1]: sh: 1: webpack-dev-server: not found 2021-01-04T05:28:48.357741+00:00 app[web.1]: npm ERR! code ELIFECYCLE 2021-01-04T05:28:48.357975+00:00 app[web.1]: npm ERR! syscall spawn 2021-01-04T05:28:48.358130+00:00 app[web.1]: npm ERR! file sh 2021-01-04T05:28:48.358313+00:00 app[web.1]: npm ERR! errno ENOENT 2021-01-04T05:28:48.363313+00:00 app[web.1]: npm ERR! p2p.chat@0.2.8 start:
webpack-dev-server --config webpack.config.js --port 3001 --hot --inline --history-api-fallback 2021-01-04T05:28:48.363392+00:00 app[web.1]: npm ERR! spawn ENOENT 2021-01-04T05:28:48.363514+00:00 app[web.1]: npm ERR! 2021-01-04T05:28:48.363633+00:00 app[web.1]: npm ERR! Failed at the p2p.chat@0.2.8 start script. 2021-01-04T05:28:48.363718+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above. 2021-01-04T05:28:49.360342+00:00 app[web.1]: 2021-01-04T05:28:49.360459+00:00 app[web.1]: npm ERR! A complete log of this run can be found in: 2021-01-04T05:28:49.360573+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-01-04T05_28_48_364Z-debug.log 2021-01-04T05:28:49.428433+00:00 heroku[web.1]: Process exited with status 1 2021-01-04T05:28:49.482487+00:00 heroku[web.1]: State changed from starting to crashed 2021-01-04T05:30:16.179886+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=gentle-mesa-42057.herokuapp.com request_id=9ccadb29-65bd-411d-970c-ad6df4a4863b fwd="182.70.147.154" dyno= connect= service= status=503 bytes= protocol=https 2021-01-04T05:30:18.907666+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=gentle-mesa-42057.herokuapp.com request_id=35402d9b-636b-4259-826c-44bb1cc55979 fwd="182.70.147.154" dyno= connect= service= status=503 bytes= protocol=https 2021-01-04T05:30:19.783263+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=gentle-mesa-42057.herokuapp.com request_id=af1618f7-18b7-45b7-9bd3-a08c8794f6ba fwd="182.70.147.154" dyno= connect= service= status=503 bytes= protocol=https 2021-01-04T05:30:23.384251+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=gentle-mesa-42057.herokuapp.com request_id=75ed86ea-86da-45bd-9cc8-70b0fe56a1de fwd="182.70.147.154" dyno= connect= service= status=503 bytes= protocol=https
What should i do help me
Initially install express using
npm install express --save
Then, follow these steps
1.Create server.js
2.Then paste these contents in
const express = require('express');
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, '')));
app.get('/*', function (req, res) {
console.log('available on localhost:9000');
res.sendFile(path.join(__dirname, '', 'index.html'));
});
app.listen( process.env.PORT || 9000);`
"scripts": {
"start": "node server.js",
"heroku-postbuild": "npm install && npm run bundle",
"test": "echo \"Error: no test specified\" && exit 1",
"bundle": "NODE_ENV=production ./node_modules/.bin/webpack --config webpack.config.js"
4.Then push the changes to github
@Pey-crypto It is showing nothing when i am going to localhost:9000
You did push on Heroku master right
No it is not on heroku I just did npm start and this is what it is showing
There were certain modifications on the npm start cmd. To see the changes push it to heroku
git commit -m "Whatever"
git push heroku master
Then you can see the change on the URL generated when the build is completed
@Pey-crypto Thank you so much for help it worked
please go through react and git
Sorry we can't give specific support like this. But this is a static website - it doesn't need a server. https://p2p.chat is deployed on netlify. You do need a signal server deployed to point at, though, as mentioned here - https://github.com/tom-james-watson/p2p.chat#architecture. That would need updating here - https://github.com/tom-james-watson/p2p.chat/blob/a87e1fe423d2d576fa0add4320f980ee958b76a7/src/js/containers/chat.js#L14.