i have a MERN stack application that i wish to deploy to heroku, in my package.json file i have the "build" command in scripts, whenever i try to deploy heroku runs the build command automatically and fails, which fails everything else..i already use build on my local machine before deploying so i don't want the script to be run again.. i checked around and found this article in herokus dev logs
https://devcenter.heroku.com/changelog-items/1573
it says if i wish to stop that from happening i need to "specify a heroku-postbuild script in package.json file."
what is this postbuild script? how can i do that? can someone give me an example please?
Not familiar with Heroku but this link provides an explanation on why you might need to build again on a deploy to Heroku and also gives a sample build script.
If you're sure you don't have to do any build on Heroku and just uploading (deploying) your files is enough, then your heroku-postbuild could just display (log) a message. The example on Heroku's website for heroku-postbuild simply displays (logs) a message.
Related
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.
I'm trying to start a NextJS application on my Node server using Plesk but it is not working. I activated NodeJS for my Plesk environment, and I was able to run npm install and npm build, but now, when I try to start the application, Plesk only shows "Please wait" and stays like that with no change, I have been waiting for more than 2 hours now, but I don't get any results, no errors, nothing.
The only issue I can think of is that, according to what I could find, the Application startup file and the package.json file should be in the same directory, the root folder, but in my case this is not possible. I have my package.json in the root directory, but the startup file for NextJS, index.js, is inside the pages folder. I tested building and starting the app locally and everything works fine, I don't understand why it's not working with Plesk.
I was able to fix this after correcting the startup file, it should be "node_modules/.bin/next" and not "pages/index.js".
Also when you start your app, Plesk will tell you to wait. Just check the site and make sure it is running, if it is, you can close Plesk.
You might need to install Express in your Next.js
You may refer to this repo fmi # https://github.com/zeit/next.js/tree/canary/examples/custom-server-express
If you're referring to the package.json's command we'll have:
dev
build
start
In Plesk's Node Application extension.
Website & Domains > "Your Domain" > Enable Node.js
Simply set server.js as my Application Startup File.
Ensure that all dependencies is installed using "Npm Install" helper.
You must run build command before start command.
Screenshot:
Helpful NPM/Plesk reference:
Running scripts in Node.js Application
Adding .npmrc file in Node.js Application Root folder
I've connected Plesk to GitHub. Plesk gives the opportunity to run additional deployment actions after a branch was pulled. Pulling the branch works fine.
But it seems, that these actions are not triggered.
I want to run the install:prod task from my package.json file.
I can run this successfully via ssh.
I've also tried to skip the prepending "npm run" part but without success.
My current configuration looks like this.
npm run install:prod
The logs are showing no error message. It seems to silently fail.
I had the same problem. The solution for me was to use the correct path on the additional deploy scripts, you can find out those by doing "which npm" and "pwd" for getting your website dir path. Once you have those you could use this lines on your deploy scripts, for example, assuming "httpdocs" is where your website is:
cd /var/www/vhosts/<your vhost>/httpdocs
/usr/bin/npm run install:prod
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
My application is based on node.js, and uses bower.js and others task runners to compile assets and build the actual assets (minify, concat, inject...).
Since this is my first application that will be running in a scalable enviroment on Heroku, I was wondering how is the process of deploying.
I mean, my current workflow is:
cd myRepo
git commit [blabla...]
git push heroku
And when running it, it runs npm run wich calls geddy and runs the server.
If I build before pushing, there will be files that are kind of redundant, but if I push the unbuilt project, it should build it on the cloud. Is that the main idea?
Thanks
it should build it on the cloud. Is that the main idea?
Correct; checkout the Dev Center for more Nodejs information:
Heroku Dev Center: Getting Started with Nodejs
Specifically here, it lists information on bower:
Heroku Node.js Support: Customizing the Build Process