Heroku Node.js Discord Bot not starting - node.js

I am currently facing an issue where my Discord Node.js bot is not starting on Heroku for some reason, despite doing everything that I could possibly find on this forum, the official documentation, youtube videos, anything.
If I run the index.js file on my computer, the bot successfully logs in, and commands I have added so far work perfectly fine. But of course I want to offload this payload to a server, that is Heroku.
My project is on a private repository on GitHub, with which I have already set up auto deploy on the Heroku dashboard (main branch).
My folder structure:
node_modules/
src/
Commands/
Data/
Events/
Structures/
index.js
.gitignore
package-lock.json
package.json
Procfile
README.md
The content of my Procfile is this (without quotes): "worker: node src/index.js"
In package.json, relevant parts are:
"main": "src/index.js",
"scripts": {
"start": "node src/index.js"
},
"engines": {
"node": "16.x",
"npm": "8.x"
},
"repository": {
"type": "git",
"url": "git+https://github.com/******/******.git"
},
"private": true
Environmental variables are also set up on the Heroku Dashboard, and it is on the gitignore list, and found at src/Data/config.json file.
I have checked the Heroku logs, and it's literally empty. It didn't even try to start yet, and on the Resources tab of the dashboard, it says "This app has no process types yet. Add a Procfile to to your app in order to define it's process types."
However, I totally have a Procfile in the folder, and on GitHub as well.
I also added the Node.js Buildpack to my app on the Heroku Dashboard.
Guys, what am I missing here? How could I finally get Heroku to launch my Node.js?
I'm gonna close this help request by a quote from one of my favorite games (We Were Here Together): "Please somebody help!" :)

Okay, figured it out. For someone in the future that runs into the same issue:
Solution was to disconnect, then reconnect the GitHub repository on the Heroku Dashboard.
Users must have a Procfile described in the question, where the js file points to the index file, with directory relative reference.
package.json must contain the start script. Version number declaration is not mandatory.

Related

NextJs vercel deployment error "routes-manifest.json" couldn't be found

My nextjs app was working properly I added some files to update my code now it is not deploying my app on vercel. gives this error
I tried googling the error but my case in unique.
This is the git repo
https://github.com/usman-174/google-calendar-frontend
These are my script tags from package.json
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next export",
"lint": "next lint",
"lint-fix": "next lint --fix"
},
next.config.js
module.exports = {
distDir: 'build',
}
I also ran into this error because the root directory of my app was not in the top-level directory of my Git repository, so Vercel was unable to find the .next folder.
I fixed it by going to the Vercel dashboard for my Vercel project, then -> Settings -> General and setting Root Directory to the subdirectory path to my application:
Issue was we were using 'latest' in package.json for next version. I fixed it to previous version of nextjs which is 12.3.1 for us seems to have fixed the deployment for now.
But still waiting for vercel support for best way to update nextjs version in deployment for vercel or is it some sort of bug their end.
Run npm run build (check all files in builded folder)
Create .next folder and move all files from build folder to .next
Commit your .next folder to vercel or maybe git.
In my case, make sure please if the folder within the project is called "web", the json name inside should be "web"!
In my case I had a few errors in my files
Error: `'` can be escaped with `'`, `‘`, `'`, `’`. react/no-unescaped-entities
Which were being hidden in the Vercel build log because I forgot I had the following in next.config.js
eslint: {
ignoreDuringBuilds: true,
}
Which just showed me the error you have instead of the actual reason it failed.
Enabling eslint indirectly solved my issue as it led me to find the real error.
Overriding the build folder fixed my issue.

Is there any way to open nw.js app from web browser?

I have a desktop application, packaged using node-webkit JS. Is there any way to open this app with IP address from other computer by browser? I just set node-remote to http://localhost:3000 in package.json but is not working when I use chrome and open the IP. There are some errors like nw is not defiend and etc. Please tell me if this way can work or not. Thanks
I don't know nwjs but if I understand correctly, you want to access to localhost in your computer from another computer.
you can not use ip to access because of NAT. but fortunaly you can do that by a third computer (that is not behind NAT). to do that use localtunel.
for more info see this.
Do you think you could paste what your package.json looks like? I've done what you are talking about. Here is what my file structure looks like:
!(https://i.imgur.com/L3M6lvx.png)
The package.json that is in my project folder:
!(https://i.imgur.com/uZV7mzr.png)
The 1st thing that I did was install my dependencies into my project folder so that I don't get the command not recognized error. I did that by going to my project folder and typing:
npm init -y
npm install nw#0.50.1-sdk nwjs-builder -D
This creates a fresh package.json and adds the modules to the file as dependencies. Then I went into my src folder and created another package.json. I set the "main" tag to my index.html
Going back to the .json in my root project folder, we add to the "script" tag:
"script": {
"dev": "nw src/ --remote-debugging-port=9222"
}
(you can make dev whatever you want)
Once you have that setup, all you need to do is run npm run dev and your app will open up. Head over to chrome and type localhost:9222 and you should be set.
It is possible to create an app that can run in a regular browser, and also in NW.js with added features when it runs inside NW.js. You would need to basically wrap anything in if statements, like
if (window.nw) {
let fs = window.nw.require('fs');
let file = fs.readFileSync('./whatever.txt');
console.log(String(file));
}
You could then create two different npm scripts. One to just run a local web server and one to run it and launch NW.js.
{
"main": "http://localhost:4467",
"node-remote": "http://localhost:4467",
"node-main": "server.js",
"scripts": {
"start": "concurrently \"npm run serve\" \"wait-on http://localhost:4467 && nw .\"",
"serve": "node server.js"
},
"dependencies": {
"express": "latest"
},
"devDependencies": {
"concurrently": "latest",
"wait-on": "latest"
}
}
Example: https://github.com/nwutils/nw-local-server-example

How to deploy React App client and Node Server to cPanel

I am trying to deploy a react app and a node server to my domain http://cv-devlabs.com/ with cPanel but failing to run. Most of the time I'm getting a "server responded with the 404 error".
I have tried methods from "hosting react app and express server cpanel" and "How to deploy a react app on cPanel?" and failed at both. I'm assuming I did something wrong here.
My file structure is:
Root-Folder--
-client
--build
--node_modules
--public
--package.json(client)(content added below)
-.gitignore
-package.json(server)(content added below)
-procfile
-server.js
Package.json (client)
"name": "client",
"homepage": "http://cv-devlabs.com/vidci-vid2/",
"version": "0.1.0",
"private": true,
"proxy": "http://localhost:8000",
Package.json(server)
{
"name": "vidci-vid",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"dotenv": "^8.2.0",
"express": "^4.17.1",
"socket.io": "^2.3.0"
},
"scripts": {
"start": "PROD=true node server.js",
"postinstall": "cd ./client && yarn"
}
}
This is working fine on Heroku but on cPanel, it's not. The whole project can be found at https://github.com/ConsultVerraton/vidci-vid.git
Thanks to anyone who can help and thanks to anyone who can try. Do let me know if more information is needed.
Thanks
You cannot host a node.js app in most providers working with cpanel. If you want to host a node.js app you should deploy it on a vps. You can follow this tutorial for example:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
But in these cpanel providers, you could host a static react app (for example an app build with create-react-app). This kind of app does not need node.js at runtime. So you can build the assets and push them to your cpanel host.
You can follow this tutorial:
https://dev.to/crishanks/deploy-host-your-react-app-with-cpanel-in-under-5-minutes-4mf6
Yes you can, but it depend if the host provider allow it.
I'm actually running a express server on a cPanel account.
I didn't found the official documentation of cPanel but this is a pretty good one: How to create a Node.js application with cPanel using the Node.js Selector
If your looking to do it in command line, this the official documentation from cPanel :How to Install a Node.js Application.
I don't know about react but for anyone who wants to know how to deploy node js app to Cpanel this is a good source for him, this explains thoroughly how to deploy node js app to cpanel please check this

Deploying to Heroku with client and api in seperate folders. Failing on Heroku

I am developing a NodeJS app that uses React on the front end. My folder structure is:
root -
- client (React App)
- api (express server)
My git folder is in the root folder for pushing the entire project to GitHub throughout development. But does my repo need to now be initialized in the api folder? Or is there a way to tell Heroku that the application is in the api folder?
Error on Heroku:
Build failed
There was an issue building your app. Please ensure your app is deployable to Heroku and try again.
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed
Also I feel it's worth mentioning that I set up the auto deploys in the Heroku GUI. So, it is attempting to build. I also have a Proc file and an app.json file.
app.json
{
"name": "Craig Bauer | Portfolio",
"description": "My web portfolio built as a MEAN stacjk app",
"repository": "https://github.com/craigbauerwebdev/Portfolio",
"logo": "",
"keywoeds": ["node", "react", "portfolio"],
"image": "heroku/nodejs"
},
{
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-node.js"
}
]
}
Procfile
web: node app.js
Thanks in advance
I found this solution and just wanted to share.
My entire production application is now in the api folder. This command worked well for me.
git subtree push --prefix api heroku master
For future projects I will structure this differently so I won't have to copy the build before each deploy.

HTML5 application on Heroku

I wish tho host my HTML5 application on Heroku. But I must choose one of the platforms (Java, Python, Node.js, etc) for my app. How can I run my application under Node.js? I have been able to create and deploy a simple Node.js app in Heroku however I am yet to figure out how can I merge my HTML5 app into this Node.js app.
I hope I make sense.
Tanks
"HTML5 app" is very non-descriptive and generic. If you mean an entirely client-side HTML application with no real backend logic, than that's trivial with node.js on heroku. If you put this in the root of your git repo in a file called server.js:
var app = require('express')();
app.use(express.static('app'));
app.listen(process.env.PORT);
Then put all of your HTML5 app in a directory called 'app' and node will serve it up.
Also in the root of your repo you'll need a Heroku Procfile with the following:
web: node server.js
Finally, you'll also want a package.json in the root of your repo so that Heroku can install your dependencies:
{
"name": "my-app",
"description": "My application",
"version": "0.0.1",
"dependencies": {
"express": "3.4.0"
},
"engines": {
"node": ">=0.10.0"
}
}
you can use ruby as well. rack based app Heroku rack based app
You need to create a config.ru file and put your HTML content into public folder
Here are more details about creating a static site based on rack app. Creating Static Sites in Ruby with Rack
Hope this helps!

Resources