[Vuejs]-MEVN app deployment to Heroku failed because of 'vue-cli-service' not found

0πŸ‘

I assume that You have installed Heroku CLI, logged in and connected to Your github account.

If so this is how I’ve deployed my project.

…

I have created a new branch i.e. deployBranch

Then in the frontend folder I have run β€˜npm run buildβ€˜.

I have copied the β€˜distβ€˜ folder to project folder.

In backend file (server.js or in your case app.js) I have added this code just after the routes:

const trajectory = path.resolve();

if (process.env.NODE_ENV === "production") {
    app.use(express.static(path.join(trajectory, "/dist")));
    app.get("*", (req, res) =>
        res.sendFile(path.resolve(trajectory, "dist", "index.html"))
    );
}

(don’t add heroku-postbuild script to package.json and delete /dist from .gitignore file in master project folder if there is one)

After this I commited all the changes to a new branch.

git push –set-upstream origin deployBranch

Then in heroku, i have created the new project.
In deploy section β€˜App connected to GitHubβ€˜ I have connected it to my project github repo.

I’ve changed the branch to deployBranch in β€˜Manual deployβ€˜ and choose β€˜deploy branchβ€˜

After that all that was left to do was to add config vars in the settings from .env

Leave a comment