My app works fine locally but when I build and move to live using heroku it just fails and following error shown in logs for the url https://polar-hamlet-97953.herokuapp.com/
2018-05-26T05:33:54.026228+00:00 app[web.1]: at /app/node_modules/sails/node_modules/async/lib/async.js:548:17
2018-05-26T05:33:54.026237+00:00 app[web.1]:
2018-05-26T05:33:54.030198+00:00 app[web.1]: Loading adapter (sails-mongo) from this app's node_modules/ directory...
2018-05-26T05:33:54.434024+00:00 app[web.1]: A hook (orm) failed to load!
Locally, it is in development mode and how to change it to production mode during deployment
Related
I created an app and ran it on my localhost which worked perfectly fine.
Then tried to deploy on Heroku, added Puppeteer Heroku and nodejs build pack.
Added the following args to the puppeteer launch function:
const browser = await puppeteer.launch({
headless: true,
args: ["--no-sandbox"],
});
also deployed with:
$ git add .
$ git commit -m "First commit"
$ git push heroku main
So far so good, no problems during deployment.
But when I open up the application, I just see that:
and get following errors in the logs:
2022-10-17T18:44:50.357107+00:00 heroku[web.1]: Starting process with command `npm start`
2022-10-17T18:44:52.117360+00:00 app[web.1]:
2022-10-17T18:44:52.117423+00:00 app[web.1]: > fetch-data#1.0.0 start
2022-10-17T18:44:52.117426+00:00 app[web.1]: > node server.js
2022-10-17T18:44:52.117429+00:00 app[web.1]:
2022-10-17T18:44:52.439078+00:00 app[web.1]: Listening on port 41022...
2022-10-17T18:44:52.441949+00:00 app[web.1]: /app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:69
2022-10-17T18:44:52.441949+00:00 app[web.1]: throw new Error(missingText);
2022-10-17T18:44:52.441949+00:00 app[web.1]: ^
2022-10-17T18:44:52.441950+00:00 app[web.1]:
2022-10-17T18:44:52.441951+00:00 app[web.1]: Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (1045629).
2022-10-17T18:44:52.441951+00:00 app[web.1]: at ChromeLauncher.launch (/app/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:69:23)
2022-10-17T18:44:52.441951+00:00 app[web.1]: at async start (/app/bot.js:13:19)
As I can see he is trying to get to "/app/node_modules/puppeteer-core/.." which would be the wrong I assume?
Anyone who can help me out or prefer something else?
Thanks in advance!
I'm having a really hard time figuring out how to deploy my app to heroku. Im new to all of this so I've tried different ways and following different tutorials but I just can't seem to find out how to do it.
This is my github repo:
https://github.com/solecity/card-deck-manager-app/tree/main
And in my logs from heroku I'm getting different errors:
2021-07-14T12:22:33.592361+00:00 app[web.1]: npm ERR! missing script: start
Starting process with command `node index.js`
2021-07-14T12:25:08.838023+00:00 app[web.1]: internal/modules/cjs/loader.js:905
2021-07-14T12:25:08.838048+00:00 app[web.1]: throw err;
2021-07-14T12:25:08.838048+00:00 app[web.1]: ^
2021-07-14T12:25:08.838049+00:00 app[web.1]:
2021-07-14T12:25:08.838049+00:00 app[web.1]: Error: Cannot find module '/app/index.js'
2021-07-14T12:27:16.812794+00:00 app[web.1]: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'express' imported from /app/server/index.js
If anyone could shed some light on how I can fix this it will be greatly appreciated
as the error states, you need to provide a start script in your package.json
apparently this is what heroku tries to runs. (error 1)
And if it doesn't find it, it runs something like node index.js (error 2)
also, you have not registered express in your dependencies in the main package.json so heroku doesn't install it. (error 3)
I'm not very used to heroku, but i think you should create 2 separate projects, and register them separately in heroku. that way he would find onlythe appropriate package.json and run.
Bot works fine locally and even in the simlulated Heroku local heroku local web, but crashes after a minute or two when hosted on their servers online.
I have installed the buildpack for puppeteer:
https://github.com/jontewks/puppeteer-heroku-buildpack
I cleared my build cache:
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache
I have tried to manually set my worker scaling to 1 heroku ps:scale web=1
This is my puppeteer browser launch arguments: {args: ["--no-sandbox", "--disable-setuid-sandbox"],}
List of my dependencies below:
discord.js
dotenv
node-fetch
puppeteer
fs
Logs are useless:
2020-05-15T11:40:56.804117+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-15T11:41:22.345051+00:00 app[web.1]:
2020-05-15T11:41:22.345073+00:00 app[web.1]: > discordbot#1.0.0 start /app
2020-05-15T11:41:22.345073+00:00 app[web.1]: > node bot.js
2020-05-15T11:41:22.345074+00:00 app[web.1]:
2020-05-15T11:42:20.278141+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-15T11:53:02.553013+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-15T11:53:25.758932+00:00 app[web.1]:
2020-05-15T11:53:25.758955+00:00 app[web.1]: > discordbot#1.0.0 start /app
2020-05-15T11:53:25.758956+00:00 app[web.1]: > node bot.js
2020-05-15T11:53:25.758956+00:00 app[web.1]:
2020-05-15T11:54:18.310840+00:00 heroku[web.1]: State changed from starting to crashed
I had a similar problem and applied this:
(Copied from Puppeteer Troubleshooting site. And It worked!)
Running Puppeteer on Heroku
Running Puppeteer on Heroku requires some additional dependencies that aren't included on the Linux box that Heroku spins up for you. To add the dependencies on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your app under Settings > Buildpacks.
The url for the buildpack is https://github.com/jontewks/puppeteer-heroku-buildpack
Ensure that you're using '--no-sandbox' mode when launching Puppeteer. This can be done by passing it as an argument to your .launch() call: puppeteer.launch({ args: ['--no-sandbox'] });.
When you click add buildpack, simply paste that url into the input, and click save. On the next deploy, your app will also install the dependencies that Puppeteer needs to run.
If you need to render Chinese, Japanese, or Korean characters you may need to use a buildpack with additional font files like https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack
There's also another simple guide from #timleland that includes a sample project: https://timleland.com/headless-chrome-on-heroku/.
This works perfectly fine locally, I've been looking through all of heroku's node deployment related documentation but haven't been able to find the solution there.
This is my terminal view after building with the first error:
terminal log after running 'git push heroku master
terminal log after running 'heroku logs'
I have a MEAN.js app that I deployed to openshift server doing the following steps:
1- setup client tools rhc, git, etc..
following this tutorial openshift tutorial
result: successfully authenticated through rhc ssh to my openshift domain
2- created a new app through the web console using the open shift provided cartridge Nodejs cartridge on openshift
3- added a mongodb cartridge the the application through openshift web console
4- Now I did a step to install bower manually to avoid committing & pushing libraries through git
using rhc ssh command on the terminal i issued npm install -g bower on the console, and it seemed to work fine, bower installed successfully
5- downloaded the nodejs app from github as guided through the setup guide now i got the folder structure of the app deployed on the server locally
6- I needed to include the following in the app folder to successfully deploy my app to the server
a- npm dependencies in the package.json file
b- bower.json file ( later i should be able to run bower install to install bower dependencies in the repo) was not successful I don't have sudo permissions on the directory
c- all the files and folder structure required to run my project
d- lines of code that setup the server to run using the configuration files that bind mongoose.js, with express.js , passport, and to listen on port 3000
to do this I included code into the existing app.js file that already setup the node server to run `
var mongoose = require('./config/mongoose'),
express = require('./config/express'),
passport = require('./config/passport');
var db = mongoose();
var app = express();
var passport = passport();`
e- commit all and push done that
result : through the rhc terminal was successful deployment
but when I visit the link on the browser I got a
503 Service Unavailable No server is available to handle this request.
I went back to the terminal and rhc ssh to the openshift server, then ran taill_all to see whats going on in the logs found the following on repeat in the terminal
==> app-root/logs/haproxy.log <== [WARNING] 134/132624 (39619) : Stopping proxy express in 0 ms. [WARNING] 134/132624 (39619) : Proxy
stats stopped (FE: 2 conns, BE: 0 conns). [WARNING] 134/132624 (39619)
: Proxy express stopped (FE: 9 conns, BE: 103 conns). [WARNING]
134/132624 (75275) : config : log format ignored for proxy 'stats'
since it has no log address. [WARNING] 134/132624 (75275) : config :
log format ignored for proxy 'express' since it has no log address.
[WARNING] 134/163313 (75275) : Server express/local-gear is DOWN for
maintenance. [ALERT] 134/163313 (75275) : proxy 'express' has no
server available! [WARNING] 134/163353 (75275) : Server
express/local-gear is UP (leaving maintenance). [WARNING] 134/163355
(75275) : Server express/local-gear is DOWN, reason: Layer4 connection
problem, info: "Connection refused", check duration: 0ms. 0 active and
0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in
queue. [ALERT] 134/163355 (75275) : proxy 'express' has no server
available!
==> app-root/logs/nodejs.log <==
at require (internal/module.js:20:19)
at module.exports (/var/lib/openshift/57375ced7628e1e8f00001bd/app-root/runtime/repo/config/express.js:54:3)
at Object. (/var/lib/openshift/57375ced7628e1e8f00001bd/app-root/runtime/repo/app.js:46:11)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32) { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to
load c++ bson extension, using pure JS version { [Error: Cannot find
module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson:
Failed to load c++ bson extension, using pure JS version Warning:
connect.session() MemoryStore is not designed for a production
environment, as it will leak memory, and will not scale past a single
process.
The problem is MEAN.IO cartidge provided by openshift is not the same project structure, or dependencies as any custom MEAN.js app, which is essentially a node.js app with mongodb and express.js for server side api routing, so it's not usable in this case such as the suggestion in the following question : suggestion to use mean.io cartridge to deploy a mean.js app
kindly help direct me towards a more direct way to deploy & configure any mean.js app on openshift, suggestions to use other servers are welcomed if there's a clear successful past experience, thanks
If you choose to edit code directly on the server (avoiding committing and pushing your changes), your work will be lost if your app ever needs to be restored or rebuilt.
Bower is usually used as a generator, to scaffold code locally (before you commit and push your changes). I don't think bower works correctly on OpenShift since it expects the $HOME dir to be writable.
I'd try doing this work locally, then commit and push the result.