Vue.js Heroku deploy not working - node.js

I'm trying to deploy a Vue.js application I made to Heroku, but I keep getting Cannot find module '/app/index.js'.
I feel like I'm just missing something small. Here is the git repo if you are wanting to look through the code. https://github.com/Relofr/calculator

You need app.js (as an example) file in your main directory with basic server configuration. You also have to run npm run build before deploying your app.
Follow this tutorial:
https://medium.com/netscape/deploying-a-vue-js-2-x-app-to-heroku-in-5-steps-tutorial-a69845ace489

You don´t have any file with the name index.js try to rename ./src/main.js to ./src/index.js

Related

index.html not found while deploying MERN app to render.com

I was trying to deploy my MERN based E-commerce website on render.com, after the render terminal shows the build was successful the the webpage shows the error as,
{“message”:“ENOENT: no such file or directory, stat ‘/opt/render/project/src/frontend/build/index.html’”,“stack”:null}
I’m a complete beginner to render and MERN too,
I have no bulid folder in my local
then I tried to create another test app by npx create-react-app test to check if build folder is actually present in there or not, But it is not there, I’m totally in Confused now…
I’m Giving my repo here → stunning spark
I just want to have clear answers for my questions(Please!!!)
Things I want to change in my directory to deploy and host my app Successfully.
Things Need to be configured in the render’s settings
Thanks in Advance!!!
I just want to deploy and host my application on render.com
Just run npm run build into your frontend folder and do check you have removed the "build" keyword from the .gitignore file because it won't let you push the build folder to GitHub and you are good to go.

Error on build in Heroku -pre-received hook declined but why?

I'm a newbie to deployment and having lots of issues and could really use some guidance! I have an app with the folder structure shown below.
When I started the deployment, I got the backend part to deploy. Screenshot attached
I did a npm build in my client folder and have the following added to the script in my backend package.json
However, when I try to then deal with including the client side, I have a problem and am getting this error.
I was following a tutorial that had a similar folder structure and deployed via
git subtree push --prefix backend heroku master
I also tried 'main' based on answers on stack overflow but it didn't change the error. I am the only one doing anything with this repository (and it's currently private), have no other branches, and I have nothing that hasn't been pushed to my repository in Github (no changes made recently) so I'm not sure what this is about. Any ideas???
I think your folder structure could be the error.
Try something like that:
projectName:
-client
-package.json
-.env
-index.js
with your project structure, Heroku can't read the index.js and the package.json. Because it is nested in your backend folder.
I think this is why you are getting this error:
Error: Cannot find module '/app/backend/server.js'

Why doesn't gcloud app deploy include my custom made module?

In my Node application script I require a custom made module which has its own dependencies. In local development this all works fine and everything works as expected. However, when I want to deploy my application as a whole through gcloud app deploy the following error occurs:
Updating service [myapp]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
> myapp#1.0.0 start /app
> node server.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'mycustommodule'
Does this have anything to do with that maybe gcloud tries to download all node modules for itself from the NPM server and therefore obviously can't find my local module? I can't figure out how to include my own node modules (that also have their own dependencies).
I thank you for thinking along with me in advance.
Help is much appreciated.
When you run the gcloud app deploy command, the SDK automatically creates a .gcloudignore file that pretty much works like .gitignore and filters out some files or directories that won't be deployed.
.gcloudignore by defaults include the node_modules/ directory so your installed dependencies aren't uploaded alongside your code. You can remove this entry from the .gcloudignore and try to deploy again.

Have the server build VS. check in & push a locally built app

What are some pro/cons to pushing built code vs. having the server build it?
This is a general question, but here's my specific scenario to illustrate what I'm talking about:
On Heroku I've got a React app that has a simple express server to do OAuth. Currently, I have a postinstall hook in my package.json that runs a webpack production config to do some extract-text stuff and create a dist/ directory with my bundled, uglifyied code. To get all of this to run on Heroku I had to mark pretty much all of my dependencies as 'dependencies' instead of 'devDependencies'.
I know it's a bad practice to check my dist/ into git but it would save me from having to install a dozen plus node_modules on the server. Any thoughts?

How do I push my build directory to Heroku?

I have a Node project with some front end that results in a ./build directory. How do I setup Heroku to understand that build is what it needs to operate and not my whole project?
Heroku gets all informations of the node.js app using the package.json that needs to be on the main path.Just configure your paths correctly in package.json and it should work fine.

Resources