[Vue warning]: Unable to find component and encountering tsconfig errors

Essentially, I have developed a component named "SelecionarIngredients" and I am trying to export it to the "ConteudoPrincipal" component. However, I encountered a Vue warn error in the browser stating that it failed to resolve the component. I attempted to make adjustments to configuration files like vite.config.ts and all tsconfig files, but this led to issues with finding other components and caused new errors in the tsconfig files. Despite trying npm updates, json updates, and various solutions, nothing seems to be resolving the issue. Any insights as to why the browser is struggling to locate and display this particular component?

**Primary Component: **

<script lang="ts">
import { defineComponent } from "vue";
**import SelecionarIngredientes from "./SelecionarIngredientes.vue";**

export default defineComponent({
  data() {
    components: {
      SelecionarIngredientes;
    }
  },
});
</script>

<template>
  <main class="conteudo-principal">
    <SelecionarIngredientes />
  </main>
</template>

// **Component being exported and cannot found when running npm run dev **

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "SelecionarIngredientes",
});
</script>

I tried updating the vite.config and tsconfig files but it did not work

**Vite.config file: **

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import tsconfigPaths from "vite-tsconfig-paths";

export default defineConfig({
  plugins: [vue(), tsconfigPaths()],
});

**tsconfig file **

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "src/**/*.css"
  ]
}

tsconfig.app.json

{
  "extends": "@vue/tsconfig/tsconfig.dom.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "exclude": ["src/**/__tests__/*"],
  "compilerOptions": {
    "composite": true,
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}

tsconfig.node.json

{
  "extends": "@tsconfig/node18/tsconfig.json",
  "include": [
    "vite.config.*",
    "vitest.config.*",
    "cypress.config.*",
    "nightwatch.conf.*",
    "playwright.config.*"
  ],
  "compilerOptions": {
    "composite": true,
    "module": "ESNext",
    "moduleResolution": "Bundler",
    "types": ["node"]
  }
}

Answer №1

The issue at hand does not pertain to component modules. When a module cannot be resolved and imported, the build process will fail and Vue warnings will not be displayed.

Based on the information provided, it seems likely that the specific warning is related to the absence of the SelecionarIngredientes component registration, causing the rendering of <SelecionarIngredientes /> to fail.

This error can be corrected by moving the component import from `data` to `components` within the component definition:

export default defineComponent({
    components: {
      SelecionarIngredientes
    }
});

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

Vue.js encountered an error: Module not found: Unable to resolve

My goal is to eventually create an open source template, but for now I am practicing with the MEVN stack without using Vue CLI and configuring webpack manually. However, I've encountered an error at this point. ERROR in ./src/app/main.js Module not f ...

How can I center align my loader inside app-root in Angular2+?

I've successfully added a basic spinner to my <app-root> in the index.html file. This gives the appearance that something is happening behind the scenes while waiting for my app to fully load, rather than showing a blank white page. However, I& ...

calculating the dynamic height of a document from top to bottom using Angular

Is there a way to dynamically calculate the height of each page from top to bottom in Angular? The syntax that works in JavaScript seems to give an error in Angular. console.log( (document.height !== undefined) ? document.height : document.body.offsetHeigh ...

Group Hover by StyleX

I recently experimented with the innovative StyleX library and encountered a particular challenge. Can a group hover effect be achieved for a component solely using this library? For instance, let's assume we have the following component in Tailwind ...

Incorporating Ionic Elements

I've been attempting to set a default segment as active in my app. After looking through other threads and questions, the solution appears to involve making changes in the segment js file located in the components folder. However, I can't seem t ...

Retrieve form data from Vuex state to make edits

I recently completed a tutorial on Vue to enhance my skills, and I'm now facing an issue while trying to make some changes. The tutorial I followed can be found here. Specifically, I have a "settings" page where users can edit their profile details. ...

Ways of utilizing a dynamic key for invoking a resource from prisma

Currently, I am attempting to implement a more general method to retrieve data from Prisma. The function in question appears as follows: import { Prisma, PrismaClient } from '@prisma/client'; import { NextApiRequest, NextApiResponse } from ' ...

Caution: The Vue Class Based Component is signalling that a property is not defined on the instance, yet it is being

I've been experimenting with creating a Vue component using vue-class-component and TypeScript. I referenced the official documentation here: https://github.com/vuejs/vue-class-component. Despite defining the data within the class as shown below, I en ...

Navigating a JSON object with TypeScript in Angular 2: A Step-by-Step Guide

I'm relatively new to Angular2 and I am currently grappling with looping through a JSON object retrieved from a GET request. Here's the JSON object in question: { Results: [{ Time: "2017-02-11T08:15:01.000+00:00", Id: "data- ...

Next.js is refusing to render an array of HTML elements

Consider this scenario where I have a block of code in TypeScript that attempts to create and display a list of elements. Here is a sample implementation: const MenuList = ():ReactElement => { const router = useRouter(), liElements:any = []; con ...

Adjusting the width of a <div> element dynamically using two array variables within a Vue.js loop

As a beginner in vuejs, I am facing a challenge in understanding its functionality. Currently, I have implemented a 'vuejs for each-loop' within a div to fetch data from a JSON object. My goal is to calculate the current distance relative to a m ...

How to show a notification message using VueJS when a link is clicked

I'm working on a Laravel and Vue application, and I've created a component that allows users to copy text to the clipboard when they click on a link. This is how it's implemented: <a @click="copyURL" ref="mylink"> ...

After compiling typescript, ES6 Map.forEach is unexpectedly not a function

Exploring the new collection types introduced in ES6 for my TypeScript/React project. interface MyComponentProps{ myMap: Map<String, {isAvailable?: boolean}>, } ... this.props.myMap.keys(); Even though IntelliJ and Webpack compile the code withou ...

Bug in Vue reactivity: experiencing issues with Vue 3, Vuex 4, class components (using Vuex Class Modules), and Inversify

I'm currently in the process of updating a vue2 project to vue3, and it's been quite an adventure upgrading most of the dependencies. I'm almost finished with the update, but I've encountered some strange bugs related to state and vue r ...

Vue's span function is yielding the promise object

In my Vue component, I am using the function getOrderCount to fetch the number of orders from a specific URL and display it in one of the table columns. <div v-html="getOrderCount(user.orders_url)"></div> async getOrderCount(link) { ...

Modify the variable value only in React when the state undergoes a change

I'm facing a situation where I need to reset the stocksHelper class and instantiate it again whenever the component renders based on a change in the stocks' useState. This is essential because upon a change in stocks, a calculation needs to be pe ...

Setting up a project in TypeScript with Angular 2(+) and a Node/Express server is essential for successful

Searching for the optimal approach for a project similar to this: An Angular 2 (4) client coded in TypeScript A Node/Express backend also written in TypeScript Utilizing some shared (TypeScript) models accessible to both client and server code. Is it pr ...

Mistakenly appearing at the top of the window instead of the bottom of the window

Utilizing Vue.js to fetch resources from a Laravel API periodically and paginate(), after retrieving the initial 10 instances, I aim to get the next 10. Here's how my method looks: scroll () { window.onscroll = () => { let bottomOf ...

Conceal player controls for HTML videos on iOS devices

How can I hide the video player controls in Windows and Android, they are hidden but still visible on iOS. I have tried different methods but can't seem to hide them. Here is what it looks like on iOS: https://i.sstatic.net/Uwrg3.png Here is my code ...

Ways to retrieve namespaced vuex within the router

I'm facing an issue while trying to access Vuex getters with namespaced modules inside the routers.js file. The getters are always returning a null value even though the user is logged in and the value should be true. Here is an example of the code: ...