I have worked with vue/vite quite a bit, and this is the first time it is happening. Currently working on a private project that I would like to publish eventually, but the following error is just spamming the console, and yet everything (as far as I can tell) works as expected:
TypeError: T is undefined
The full error looks like this, but is fairly irrelevant I assume, since it points to nothing specific.
It only happens when built and deployed, not when running npm run dev
.
The error occurs 4 times each time the page is loaded. I have used this exact same setup multiple times before, and never had an issue. I can only imagine that something happens during the built process?
Does anyone have any clue how to proceed here? For now these errors seem cosmetic, but I'd rather not have them regardless.
This is my main.js:
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import { createStore } from 'vuex'
import axios from "axios";
const app = createApp(App)
app.config.globalProperties.$BASE_API = import.meta.env.VITE_NETWORK_API ? import.meta.env.VITE_NETWORK_API : "http://127.0.0.1:5000/api/app/"
async function test() {
try{
const test = await axios.get(app.config.globalProperties.$BASE_API+"/hello")
if(test) console.log("MADE CONTACT!!")
}catch(err){
console.log("no contact...")
console.log(err)
}
}
test()
This is index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="/assets/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
And this is the Dockerfile that builds it:
FROM node:lts-alpine AS build-stage
ARG DEPLOYENV
ARG VERSENV
ARG DATEENV
WORKDIR /app
COPY ./myapp/package*.json .
RUN npm install
COPY ./myapp .
RUN echo "VITE_DEPLOYENV=testing" > .env
RUN echo "VITE_VERSENV=v0.1" >> .env
RUN echo "VITE_NETWORK_API=http://192.168.x.y:6602/api/app/v1" >> .env
RUN npm run build
FROM docker.io/nginxinc/nginx-unprivileged AS prod-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
COPY ./myapp/public /usr/share/nginx/hmtl
COPY nginx.conf /etc/nginx/
RUN rm /etc/nginx/conf.d/default.conf
EXPOSE 9080
CMD ["nginx","-g","daemon off;"]
as well as my packages:
{
"name": "myapp",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.8.3",
"chart.js": "^4.4.8",
"chartjs-adapter-date-fns": "^3.0.0",
"chartjs-plugin-annotation": "^3.1.0",
"vue": "^3.5.13",
"vue-router": "^4.5.0",
"vuex": "^4.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.1",
"vite": "^6.2.0"
}
}