Heroku deploy stuck in build - heroku

I want to deploy a MERN stack application to heroku.
Everything is fine when I run heroku local but when I want to deploy it loops in build process and keeps running build. no errors in logs.
package.json
"scripts": {
"start": "cd server && node server.js",
"client": "cd client && npm start",
"server": "nodemon server.js",
"build": "cd client && npm install && npm run build",
"dev": "concurrently \"npm run server\" \"npm run client\""
},
heroku logs
2021-09-22T09:30:16.363135+00:00 app[api]: Release v1 created by user /* my email here */
2021-09-22T09:30:16.363135+00:00 app[api]: Initial release by user /* my email here */
2021-09-22T09:30:16.609550+00:00 app[api]: Enable Logplex by user /* my email here */
2021-09-22T09:30:16.609550+00:00 app[api]: Release v2 created by user /* my email here */
2021-09-22T09:32:37.000000+00:00 app[api]: Build started by user /* my email here */

so after a couple of hours hitting the keyboard with my head I deleted .git folder and initialized git again , and deployed, this should work for you if this is the only error you are getting.

Related

How can I deploy my MERN application on Heroku

I'm trying to deploy my MERN application on Heroku but it gives me an error: concurrently: not found
how can I fix the issue?enter image description here
I added "concurrently": "npm start" on script in package Jason, but it giving me the same error

I have to run cypress component Test but my application is taking approx 17 mins to bootup. So, it is creating timeout error

I am using start-server-and-test but it is giving timeout error after 10 mins. I am following cypress documentation only.
https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
Another package that I used is npm wait-on but it is also not working
"scripts": {
"dev": "cd ../../ && npm run start",
"run:component": "cypress run --spec integration/component_test/*.spec.js",
"componentTest": "npm run dev wait-on http://localhost:3000/ && run:component",
},
I am running "npm run componentTest" but it is not running NEXT_CMD command i.e. run:component
Any suggestion would be really appreciated.
wait-on has a --httpTimeout option, maybe this will work
"componentTest": "npm run dev wait-on --httpTimeout 1020000 http://localhost:3000/ && run:component"
You could potentially wait multiple times and ignore the exit status of all but the last wait invocation.
However I think the main issue here is that run dev and wait-on is not propely running in paralell. Based on this gist the proper invocation should be
"scripts": {
"dev": "cd ../../ && npm run start",
"run:component": "cypress run --spec integration/component_test/*.spec.js",
"componentTest": "concurrently \"npm run dev\" \"wait-on http://localhost:3000/ && npm run run:component\" --kill-others"
},
which will start both concurrently. I added a script similar to this in our project and it worked as intended.
Possibly the start-server-and-test package could be used instead of concurrently.

Run Heroku Bash Command 7/24

I have to open the Heroku bash and type "node main.js" to run my app. But when I close my browser the script stops. How can I run the script 24/7?
You seem to be new to heroku, this should help
In your package.json file mention a start script:
"scripts": {
"start": "node main.js",
...
}
(If you don't have a package.json make sure to run npm init -y and commit this file)
And to scale(run) your app:
heroku ps:scale web=1
Your heroku app should automatically be detected as a node application and it would run the start script upon starting
To see the logs and debug, do:
heroku logs --tail --num=10
and then try visiting your app with the terminal open to see live logs
If you have further problems, make sure to include your logs without any credentials possibly leaked

Attach debugger to Strapi server

How to start Strapi with --inspect=0.0.0.0:9229 parameter or any other way to attach the debugger to my server?
This is how I could manage that with alpha version but server.js has been removed since beta:
package.json -> scripts
"debug": "cross-env NODE_ENV=development nodemon --inspect=0.0.0.0:9229 server.js"
Never mind,
node --inspect=0.0.0.0:9229 ./node_modules/.bin/strapi dev
does the trick.
node --inspect=0.0.0.0:9229 ~/path/to/project/node_modules/#strapi/strapi/bin/strapi develop

How to deploy parse dashboard to heroku

I have deployed the parse server on heroku (https://github.com/ParsePlatform/parse-server) but can't find anything to deploy the parse dashboard on heroku. Any reference is appreciated!!
You shouldn't have to clone the parse-dashboard repository. Here is a better way using parse-dashboard as a node module.
Create a new node app:
mkdir my-parse-dashboard
cd my-parse-dashboard
npm init
Fill out the details it asks for.
Create a git repository:
git init
Additionally you can push this git repository to a remote server (e.g. Bitbucket). Note this repository should be private since it will contain your master key.
Install the parse-dashboard package:
npm install parse-dashboard --save
Create an index.js file with the following line:
require('parse-dashboard/Parse-Dashboard/index.js');
Create a parse-dashboard-config.json file which looks like this:
{
"apps": [
{
"serverURL": "your parse server url",
"appId": "your app Id",
"masterKey": "your master key",
"appName": "My Parse App"
}
],
"users": [
{
"user":"username",
"pass":"password"
}
]
}
Update your package.json file and add this section (or modify it if it already exists):
"scripts": {
"start": "node ./index.js --config ./parse-dashboard-config.json --allowInsecureHTTP=1"
}
Note: The allowInsecureHTTP flag seems to be required on Heroku. Thanks to #nsarafa for this.
Commit all your changes and merge them into master.
Create a new Heroku app: heroku apps:create my-parse-dashboard
Run git push heroku master to deploy your app to Heroku.
Remember to generate a strong password as your dashboard is accessible to anyone on the internet. And make the dashboard only accessible through SSL else your password will be sent in clear text. Read this tutorial on how to force all traffic over SSL on Heroku with Cloudflare for your domain.
I just managed to get this working. Here are the steps I took.
Clone parse-dashboard to your local machine.
Run npm install inside that directory.
Update package.json and change the "start" script to:
"start": "node ./Parse-Dashboard/index.js --config ./Parse-Dashboard /parse-dashboard-config.json --allowInsecureHTTP=1"
(Thanks to nsarafa's answer above for that).
Edit your .gitignore file and remove the following three lines:
bundles/Parse-Dashboard/public/bundles/Parse-Dashboard/parsedashboard-config.json
Edit your config file in Parse-Dashboard/parse-dashboard-config.json, making sure URLs and keys are correct. Here is an example :
{
"apps": [
{
"serverURL": "https://dhowung-fjird-52012.herokuapp.com/parse",
"appId": "myAppId",
"masterKey": "myMasterKey",
"appName": "dhowung-fjird-40722"
}
],
"users": [
{
"user":"myUserName",
"pass":"Str0ng_?Passw0rd"
}
]
}
Remove the cache from your heroku parse server app :
heroku config:set NODE_MODULES_CACHE=false --app yourHerokuParseServerApp
if we follow the example above
yourHerokuParseServerApp = dhowung-fjird-40722
(Again, thanks to nsarafa).
Add, commit and push your changes.
Deploy to Heroku again using their CLI or the dashboard.
Step 4 was the key for me because I wasn't committing my config file, and it took me a while to realise.
Also, as stated above, make sure you have user logins and passwords in your config file, following the parse-dashboard docs:
PS: on your heroku parse server make sure your SERVER_URL looks like this https://yourHerokuParseServerAppName.herokuapp.com/parse
Update brew brew update
Install heroku-cli brew install heroku-toolbelt
Login via command line with your heroku credentials heroku login
Make sure your app is there heroku list and note YOURHEROKUAPPSNAME containing the parse-dashboard deployment
Tell Heroku to ignore the cache from previous deploys heroku config:set NODE_MODULES_CACHE=false --app YOURHEROKUAPPSNAME
Go to your package.json and change start: node ./Parse-Dashboard/index.js to start node./Parse-Dashboard/index.js --config ./Parse-Dashboard/parse-dashboard-config.json --allowInsecureHTTP=1"
Delete your Procfile rm Procfile
Add, commit and merge to your master branch
Run git push heroku master
The start script inside your package.json overrides whatever you declare inside of the Procfile. This process should enable a clean deploy to Heroku. Please be cautious and generate user logins with strong passwords before performing this deployment per the parse-dashboard documentation.

Resources