<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Opeyemi Ilesanmi</title>
    <description>The latest articles on DEV Community by Opeyemi Ilesanmi (@ilejohn).</description>
    <link>https://dev.to/ilejohn</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F891432%2Fba12071a-7559-4872-b792-861e34ec93ef.png</url>
      <title>DEV Community: Opeyemi Ilesanmi</title>
      <link>https://dev.to/ilejohn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilejohn"/>
    <language>en</language>
    <item>
      <title>Deploy Vue 3 App to Heroku via Github</title>
      <dc:creator>Opeyemi Ilesanmi</dc:creator>
      <pubDate>Thu, 14 Jul 2022 20:27:41 +0000</pubDate>
      <link>https://dev.to/ilejohn/deploy-vue-3-app-to-heroku-via-github-4a49</link>
      <guid>https://dev.to/ilejohn/deploy-vue-3-app-to-heroku-via-github-4a49</guid>
      <description>&lt;h2&gt;
  
  
  Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Intro&lt;/li&gt;
&lt;li&gt;Link the app to heroku via Github Connect&lt;/li&gt;
&lt;li&gt;Go live&lt;/li&gt;
&lt;li&gt;
Fixing the errors

&lt;ul&gt;
&lt;li&gt;Serve app with express&lt;/li&gt;
&lt;li&gt;Fix vite issue&lt;/li&gt;
&lt;li&gt;Change heroku environment settings&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;So you're trying to test your Vue skills or you need to share your work with someone else by deploying your Vue 3 app to a live environment and of the many &lt;a href="https://www.websiteplanet.com/blog/best-free-cloud-hosting-services/" rel="noopener noreferrer"&gt;free cloud hosting platforms&lt;/a&gt;, you've decided to use &lt;a href="https://www.heroku.com" rel="noopener noreferrer"&gt;heroku&lt;/a&gt; but there's this bug you are encountering after all is set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;heroku[router]: &lt;span class="nv"&gt;at&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;error &lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;H10 &lt;span class="nv"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"App crashed"&lt;/span&gt; &lt;span class="nv"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;GET &lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You've googled all around and no solution or the tutorials/articles available are only for Vue 2. This is what has led to the article you now read. &lt;/p&gt;

&lt;p&gt;So either you've faced this error or you just need a guide, follow on as I walk you through. I'll be connecting the app to Heroku via Github and not the heroku cli. In my opinion, this is easier to integrate and you can set up CI/CD with the click of few buttons without the need for &lt;em&gt;yaml files&lt;/em&gt; configuration.&lt;/p&gt;

&lt;p&gt;I assume you have a running Vue 3 app and you've pushed it to &lt;a href="https://github.com" rel="noopener noreferrer"&gt;Github&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Link the app to heroku via Github Connect.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;login to your heroku account and go to your dashboard. Click on 'New', give it a name and select 'Create new app'. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1tw2du1rjxhjl1xfvxf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv1tw2du1rjxhjl1xfvxf.png" alt="App on heroku"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the 'Deployment method' section, select Github.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hznwgynfwn3hsbuggwa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hznwgynfwn3hsbuggwa.png" alt="deployment method selction"&gt;&lt;/a&gt; then follow the process to authorise heroku to have access to your github repository then select/search your code repo and connect it.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ptclv0wnqmwydub4vjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ptclv0wnqmwydub4vjc.png" alt="heroku app connected to github"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is where you get CI/CD integration easily. On the 'Automatic deploys' section you can choose to have your app deploy automatically whenever you push to the branch of your choice. isn't that nice?&lt;/p&gt;

&lt;h2&gt;
  
  
  Go live
&lt;/h2&gt;

&lt;p&gt;On the 'Manual deploy', we will now deploy our app by clicking on 'deploy branch' and heroku will attempt to build it and make it available on a url accessible link.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqihwxox609svvs8ijo5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqihwxox609svvs8ijo5r.png" alt="Deployed app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;it tells us our app deployed successfully but when we try to view it, it shows us 'Application error'. and when we check our logs(More &amp;gt; View Logs) we see this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;2022-07-13T19:01:34.763285+00:00 heroku[router]: &lt;span class="nv"&gt;at&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;error &lt;span class="nv"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;H10 &lt;span class="nv"&gt;desc&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"App crashed"&lt;/span&gt; &lt;span class="nv"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;GET &lt;span class="nv"&gt;path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt; &lt;span class="nv"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;vue-app-heroku-github.herokuapp.com &lt;span class="nv"&gt;request_id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;90dddd7c-ec38-4a5c-8423-4953a1c199ea &lt;span class="nv"&gt;fwd&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"105.112.183.72"&lt;/span&gt; &lt;span class="nv"&gt;dyno&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;connect&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;503 &lt;span class="nv"&gt;bytes&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;protocol&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so what could be wrong? In deploying an app, Heroku tries to auto detect what kind of app it is and applies an appropriate builder and looks for the entry file/script instruction. So it sees a package.json script and thinks our app is a node.js app and hence applies the node.js builder as can be seen from the builder logs(Activity &amp;gt; view builder log). &lt;/p&gt;

&lt;h2&gt;
  
  
  Fixing the errors
&lt;/h2&gt;

&lt;p&gt;To fix the error we are going to make our Vue app into a Node.js served app so the heroku Node.js bundler can build it for us. we'll be using the packages &lt;code&gt;express&lt;/code&gt; and &lt;code&gt;serve-static&lt;/code&gt; then we'll add a "start" script instruction to our package.json file and change the configuration on our heroku environment if error persist.&lt;/p&gt;

&lt;h3&gt;
  
  
  Serve app with express
&lt;/h3&gt;

&lt;p&gt;Go back to your terminal and run the command below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;express serve-static
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So express(a Node.js framework) will serve as our app entry router and serve-static will serve the file after vite must have compiled it for the vue-router to use it's router feature.&lt;/p&gt;

&lt;p&gt;Next, create a javascript file at the root directory of your app and paste the following code into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;serveStatic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;serve-static&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;//initialise the express package&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;//use the serve-static package to serve the bundled app files in the dist directory&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;serveStatic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dist&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;

&lt;span class="c1"&gt;// this * route is to serve project on different page routes except root `/`&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/.*/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/dist/index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;//heroku automatically assigns port so leave it to do it's&lt;/span&gt;
&lt;span class="c1"&gt;//work, don't set a port in the heroku dashboard. while the&lt;/span&gt;
&lt;span class="c1"&gt;//5000 or whatever number you set will be for your local&lt;/span&gt;
&lt;span class="c1"&gt;//machine.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`app is listening on port: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Heroku needs a "start" script instruction so we're going to add one. so navigate to your package.json file and modify the "scripts" section to look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"preview"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"vite preview --port 4173"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"lint"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where &lt;code&gt;index.js&lt;/code&gt; is the name of the javascript file we created earlier. At this point if your app is a fresh install then your app should now be accessible when you click "Open App".&lt;/p&gt;

&lt;p&gt;This is what I was able to gather from the internet, thanks to tutorials like &lt;a href="https://dev.to/anjolaogunmefun/deploy-vue-js-projects-to-heroku-1hb5"&gt;this&lt;/a&gt; and &lt;a href="https://www.codementor.io/@ravianand1988/easily-4-steps-to-continuous-delivery-auto-deploy-vue-js-app-on-heroku-xljk977pq" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However if you're using an existing app that's large in size and or you're encountering an error that seems to trace itself to vite from the application logs then follow on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fix vite issue
&lt;/h3&gt;

&lt;p&gt;In vue 2, the vue-cli was used to build the app for production however in vue 3, there is a change to &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;vite&lt;/a&gt;. Vite has an &lt;a href="https://vitejs.dev/guide/static-deploy.html#heroku" rel="noopener noreferrer"&gt;instruction guide&lt;/a&gt; for deploying apps based on it to heroku but the build pack used is deprecated as at the writing of this article. &lt;/p&gt;

&lt;p&gt;From a Stack Overflow &lt;a href="https://stackoverflow.com/a/72318409/9157239" rel="noopener noreferrer"&gt;answer&lt;/a&gt;, I got to know that heroku sometimes prunes packages in devDepencies in production mode and this is where vite is registered meaning it won't be able to build successfully in that scenario. So we're going to use the npx(Node Package Executor) command to tell the deployment to execute the vite command needed to build our app. In the scripts section of package.json file, add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"prestart"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npm run build"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"npx vite build"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"node index.js"&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;prestart&lt;/code&gt; may not be necessary but just to ensure the build runs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Change heroku environment settings
&lt;/h3&gt;

&lt;p&gt;We'll also turn off production mode so that vite won't be pruned when heroku is building our app so we'll set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NODE_ENV=development
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;on our heroku dashboard via settings &amp;gt; Config Vars. (I assume this app is not really for production else if vite issues persist, you may need to remove it from devDependcies into dependecies though that isn't optimal) Also we're going to set&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NODE_MODULES_CACHE = false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;so it won't use previously cached node modules. If you have environmental variables, i.e those set in your .env file, you can set them here as well. Remember your .env file should not be pushed to github for security reasons. &lt;em&gt;In Vue 3 the convention for environmental variables is VITE_XXXX&lt;/em&gt;. so let's say you have an API_URL variable you're sending requests to then it will be VITE_API_URL.&lt;br&gt;
Then push your changes to Github and if you already enabled automatic deploys from GitHub in  Deploy &amp;gt; Automatic deploys. Your app should be available when you click "Open app" or you can manually deploy as well.&lt;/p&gt;




&lt;p&gt;This is my first article on dev.to but not my first time here. Let me know if this helped you or any other comments! &lt;br&gt;
Header Image by &lt;a href="https://www.linkedin.com/in/ilesanmi-peter-068956165" rel="noopener noreferrer"&gt;Mr PAI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>heroku</category>
      <category>github</category>
      <category>node</category>
    </item>
  </channel>
</rss>
