Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Deploying Vue.js Application to Ubuntu Server

Hello all,
I am working on deploying my first Vue.js application, I have everything working on my dev machine, I created a server and now I am pushing it up to the server and I get this error when I run :

JavaScript
npm run build
Error loading /var/www/html/vue/vue.config.js Error ENOENT: no such file or directory open /root/.aspnet/https/vue.key


This is a vue.js project being built in Visual Studio 2022. with a .Net 6 API for the backend. I have everything working, just deploying it seems to be my current issue I am running into.

JavaScript
vue.config.js

const fs = require('fs')
const path = require('path')
const webpack = require('webpack')

const baseFolder =
    process.env.APPDATA !== undefined && process.env.APPDATA !== ''
        ? `${process.env.APPDATA}/ASP.NET/https`
        : `${process.env.HOME}/.aspnet/https`;

const certificateArg = process.argv.map(arg => arg.match(/--name=(?<value>.+)/i)).filter(Boolean)[0];
const certificateName = certificateArg ? certificateArg.groups.value : "ServiceVue";

if (!certificateName) {
    console.error('Invalid certificate name. Run this script in the context of an npm/yarn script or pass --name=<<app>> explicitly.')
    process.exit(-1);
}

const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);

module.exports = {
 //   extends: ['plugin:vue/base'],
 //   rules: {
 //       'vue/script-setup-uses-vars': 'warning',
    //},
    devServer: {
        disableHostCheck: true,
        https: {
            key: fs.readFileSync(keyFilePath),
            cert: fs.readFileSync(certFilePath),
        },
        proxy: {
            '^/weatherforecast': {
                target: 'https://localhost:5001/'
            }
        },
        port: 5002
    }

}


would creating my own self signed cert possibly fix this?

What I have tried:

I have tried changing the config file and when I publish it on my dev machine everything works without any errors. When I do npm run build on my prod server I get this error about .key (certificate I'm assuming) missing.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900