I noticed that the ./src/main.js file is present in multi (webpack)-dev-server/client, but unfortunately I do not have the main.js file. I am

I'm currently working on a Vue.js 3 application demo using tailwind and typescript. Each time I try to run the app, I encounter an error message that says:

This relative module was not found:

* ./src/main.js in multi (webpack)-dev-server/client?https://192.168.2.102:8090&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

main.ts

import { createApp } from 'vue';
import App from './App.vue'
import router from './router'
import './styles/app.css';

createApp(App)
    .use(router)
    .mount('#app');

App.vue

<template>
    <div class="justify-center flex bg-yellow-300 items-center h-screen">
        <div class="text-4xl">
            {{ hello }} 👋🏼
        </div>
    </div>
</template>

<script lang="ts">
import {Vue} from "vue-property-decorator";

export default class App extends Vue {

    hello = 'Hello world'

}
</script>

vue.config.js

module.exports = {
    devServer: {
        proxy: {
            '^/api': {
                target: 'http://localhost:8081'
            }
        }
    }
}

package.json

{
  "name": "demo",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve --port 8090 --https true",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^3.0.0",
    "vue-property-decorator": "^9.1.2",
    "vue-router": "^4.0.12"
  },

Has anyone faced this issue before as well?

Answer №1

Did you know that @vue/cli actually utilizes webpack behind the scenes? If you ever need to tweak webpack's configuration, you can do so by accessing the vue.config.js file and manually updating the app's entry point. Check out the documentation here for more details.

But if you want to seamlessly integrate TypeScript into your existing @vue/cli project, it is recommended to simply add the dedicated plugin by running

vue add typescript

at the root of your project directory. This eliminates the need to manually convert your files from .js to

.ts</code, as the script will handle everything for you. Plus, it will automatically make the necessary webpack configuration changes, including switching the entry point from <code>src/main.js
to src/main.ts.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with Vuex state not updating because the state.dispatch method is not being called

In my current project, I am incorporating Vue and a Vuex store. Below is the Vuex store setup: export default new Vuex.Store({ state: { inventoryPageNumber: 0, inventoryPageCount: 0, }, getters: { getinventoryPageNumber ...

Leverage the visibilitychange event in Nuxt by utilizing the useHead function

For each page, I always set the title using useHead({title: ""});. In the layout/default.vue file, I have added the following code: useHead({ titleTemplate: title => { let titleDefault = 'Company suffix'; if (title) { ...

Troubleshooting issue: Webpack dev server's Hot Module Replacement not functioning correctly when

I've been working on a Vue 2 application that is mostly JavaScript, and now I am looking to incorporate some new TypeScript modules and components into it. Everything runs smoothly when I start the webpack dev server. However, whenever I make a chang ...

Utilizing Vue and routes to streamline communication between components

Recently delving into Vue.js, I've hit a roadblock. My goal is to pass information from one component to another through routes. For example, when navigating from 'teacher' to 'student list' and then selecting the first student, i ...

Experiencing difficulties installing fonts on Nuxt/Tailwind

I followed the instructions in this answer precisely, but my custom font class is still not working: tailwind.config.js: module.exports = { theme: { fontFamily: { "intro-regular": "intro-regular" }, extend: { ...

The function for batch insertion only functions with Postgresql and SQL Server databases

I am a beginner in JavaScript and I am currently working on creating a new restaurant. I have come across a code snippet that inserts a relation into a join-table: await newRestaurant.$relatedQuery('tags', trx).relate(tagIds); Is it not possible ...

"Angular application experiencing navigation blockage due to multiple concurrent HTTP requests using RxJS - Implementation of priority-based cancel queue

I've come across similar threads, but I have yet to find a suitable solution for my specific issue. Situation: Currently, I'm navigating on both the server side and client side simultaneously. This entails that every frontend navigation using ro ...

``Is there a specific scenario where the use of getInitialProps is recommended when automatically redirecting from one

Within my application, I have set up an auto-redirect from the root directory '/' to '/PageOne' with the following code: const Home = () => { const router = useRouter(); useEffect(() => { router.push('/pageone', ...

How to define an array of objects in data using Vue.js and TypeScript

Encountering errors when attempting to declare an array of objects in Vue.js 3 + TypeScript. The code snippet includes a template, script, and style sections. <template> <ul > <li v-if="!items.length">...loading</li> ...

Encountering a problem in vue.js: "The instance is referencing 'step1_category' which is not defined as a property or method during render"

I encountered an error that says, "Property or method 'step1_category' is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializin ...

Issues with the compatibility of the latest JSX Transform, featuring React 16.14, Typescript 4.1.0-beta, and react-scripts 4.0.0-next.98 have

Referencing the information from this source. Here is a snippet from my package.json file: "react": "^16.14.0", "react-dom": "^16.14.0", "react-scripts": "4.0.0-next.98", "typescript": ...

Is it possible to transform a reference to a React Component into JSON format?

I am looking to serialize the state of a React component into JSON format and save it in a database. Here is the current structure of my code: const [exampleState, setExampleState] = useState([ { componentName: "Test component", co ...

Converting an Array of Objects into a single Object in React: A Tutorial

AccessData fetching information from the database using graphql { id: '', name: '', regions: [ { id: '', name: '', districts: [ { id: '', ...

How does a browser decide to load content from an http URL when the frontend source is using an https URL?

When using my Vue component to load external content in an iframe, everything works fine locally. However, once I deploy it to my HTTPS site, I encounter an issue. <iframe src="https://external-site" /> Upon deployment, I receive the following erro ...

Disallow the use of restricted globals in a TypeScript project when utilizing Object.values in ESLint

Encountering an ESLint error related to no restricted globals: const objectParamsAllNumbers = (obj: Object) => !Object.values(obj).find(elem => { return isNaN(elem); }); After attempting to include ES2017.Object in the tsconfig, the error i ...

Ways to check if an array is empty in Typescript

Every time I attempt to log in, the first thing I do is validate the search data stored in the database by querying information from a matrix. This code can be found in login.controller.ts export async function postLogin(req: Request, res: Response): Pro ...

Named functions in Typescript within functional components are the best practice for improving

How can I implement handleFoo using MyType['foo']? type MyType { foo: () => void } const Comp: React.FunctionComponent<{}> = () => { function handleFoo() {} return ... } I'm looking for a solution that doesn't inv ...

Vue 3 Electron subcomponents and routes not displayed

Working on a project in Vue3 (v3.2.25) and Electron (v16.0.7), I have integrated vue-router4 to handle navigation within the application. During development, everything works perfectly as expected. However, when the application is built for production, the ...

What is the process for exporting a plugin from dayjs() in JavaScript?

Currently, I have incorporated the plugin isToday() to enhance the capabilities of dayjs(). Nevertheless, I am uncertain about how to export isToday() in order to utilize it across other files. import isToday from "dayjs/plugin/isToday"; expor ...

What causes dates to shift by 24 hours?

I am facing an intriguing datetime dilemma. It seems like I just can't crack it and it's driving me crazy. Perhaps I overlooked something or didn't approach it in the right way. Currently, I am retrieving data from Mongo using Axios. The da ...