The NUXT project encounters issues when trying to compile

I am currently working on an admin panel using the nuxt + nest stack.
I am utilizing a template provided at this link: https://github.com/stephsalou/nuxt-nest-template

While in development mode, the project starts up without any issues. However, when I try to build it, errors pop up immediately. The problem seems to be with a file compiled by nuxt itself.

  11 | export const LoadingPanel = () => import('../../client/components/LoadingPanel.vue' /* webpackChunkName: "components/loading-panel" */).then(c => wrapFunctional(c.default || c))
  12 | export const Modal = () => import('../../client/components/Modal.vue' /* webpackChunkName: "components/modal" */).then(c => wrapFunctional(c.default || c))
> 13 | export const  = () => import('../../client/components/index.ts' /* webpackChunkName: "components/" */).then(c => wrapFunctional(c.default || c))
     |               ^
  14 | export const Breadcrumb = () => import('../../client/components/Breadcrumb/Breadcrumb.vue' /* webpackChunkName: "components/breadcrumb" */).then(c => wrapFunctional(c.default || c))
  15 | export const BreadcrumbItem = () => import('../../client/components/Breadcrumb/BreadcrumbItem.vue' /* webpackChunkName: "components/breadcrumb-item" */).then(c => wrapFunctional(c.default || c))
  16 | export const BreadcrumbRouteBreadcrumb = () => import('../../client/components/Breadcrumb/RouteBreadcrumb.vue' /* webpackChunkName: "components/breadcrumb-route-breadcrumb" */).then(c => wrapFunctional(c.default || c))

Upon investigation, I discovered the root cause of this error. It appears that in the components folder, there is an index.ts file that collects all the components. Nuxt seems to interpret all files within the component folder as components and combines them into one form. These components are crucial to the admin template, and removing the index.ts file could potentially break the entire setup. A similar issue occurred in development mode, but converting index.js to index.ts resolved it.

How can I go about solving this problem?

Nuxt Configuration

const config: NuxtConfig = {
  // Disabling nuxt telemetry
  telemetry: false,
  /*
   ** Nuxt rendering mode
   ** See https://nuxtjs.org/api/configuration-mode
   */
  mode: 'universal',
  // base nuxt src dir
  srcDir: './client',
  /*
   ** Nuxt target
   ** See https://nuxtjs.org/api/configuration-target
   */
  target: 'server',
  /*
   ** Headers of the page
   ** See https://nuxtjs.org/api/configuration-head
   */
  head: {
    title: 'Admin Products SeaRates',
    meta: [
      {charset: 'utf-8'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1'},
      {
        hid: 'description',
        name: 'description',
        content: process.env.npm_package_description || '',
      },
    ],
    link: [
      {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'},
      { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Poppins:200,300,400,600,700,800'},
      { rel: 'stylesheet', href: 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/css/all.min.css'}
    ]
  },
  router: {
    linkExactActiveClass: 'active'
  },
  /*
   ** Global CSS
   */
  css: [
    '@/assets/scss/index.scss',
    '@/assets/css/demo.css',
    '@/assets/css/nucleo-icons.css'
  ],
  /*
   ** Plugins to load before mounting the App
   ** https://nuxtjs.org/guide/plugins
   */
  plugins: [
    `@/plugins/dashboard-plugin.js`
  ],
  /*
   ** Auto import components
   ** See https://nuxtjs.org/api/configuration-components
   */
  components: true,
  /*
   ** Nuxt.js dev-modules
   */
  buildModules: [
    '@nuxt/typescript-build',
  ],
  netlify: {
    headers: {
      '/*': [
        'Access-Control-Allow-Origin: *',
        `X-Build: ${pkg.version}`
      ],
      '/favicon.ico': [
        'Cache-Control: public, max-age=86400'
      ]
    }
  },
  /*
   ** Nuxt.js modules
   */
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxt/content',
    'cookie-universal-nuxt'
  ],
  publicRuntimeConfig: {
    axios: {
      baseURL: `${url}/api`
    }
  },
  /*
   ** Axios module configuration
   ** See https://axios.nuxtjs.org/options
   */
  axios: {},
  /*
   ** Content module configuration
   ** See https://content.nuxtjs.org/configuration
   */
  content: {},

  loading: { color: '#389466' },

  /*
   ** Build configuration
   ** See https://nuxtjs.org/api/configuration-build/
   */
  build: {

  },
  alias: {
    "@/*": resolve(__dirname, './client'),
  }
}

export default config

Answer №1

Why are you importing all the components when Nuxt already has auto-importing feature? Consider using either one method or the other. You can also exclude a specific component by adding the following code to your nuxt.config.js file

components: [
  {
    path: '~/components/',
    pathPrefix: false,
    pattern: `**/*.{vue,js,ts}`,
    ignore: ["~/components/index.ts"]
  }
]

If you don't use TypeScript, the default configuration fetches .vue and .js files.

The pathPrefix option is helpful if you want to include nested components, as explained here.

Use ignore to exclude importing the index component.

Lastly, you may find it beneficial to read this tutorial to learn how to work with Nuxt components more efficiently: https://nuxtjs.org/tutorials/improve-your-developer-experience-with-nuxt-components/

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

send back the result to the primary function

I need help with this code. I'm trying to return the budget from callbacks in the main function. How can I return a value from the main function? // This method returns the current budget of the user getCurrentBudget: function (req) { var reqTok ...

Parentheses are automatically wrapped around the implicit return of arrow functions

Currently, I am utilizing Visual Studio Code along with Prettier, and I have noticed that the function: (token: string) => this.token = token is being transformed into: (token: string) => (this.token = token) This modification seems to decrease r ...

core.js encountered an issue at line 6210: TypeError - The function this.service.addDepartment does not exist

Whenever I attempt to click the 'Add' button on a web application that I'm constructing, an error pops up. core.js:6210 ERROR TypeError: this.service.addDepartment is not a function at AddEditDepComponent.addDepartment (add-edit-dep.componen ...

Tips for updating a column with just one button in AngularJS

On my list page, there is an Unapproved button. I am new to angular and struggling to figure out how to retrieve the post's id and update the corresponding column in the database to mark it as approved. Can someone provide guidance on how to accomplis ...

Allowing the contenteditable attribute to function only on a single line of

My app allows users to create different lists, with the ability to edit the name. However, I am facing an issue where if a user types a new name, it should remain on only one line. I tried adding max height and overflow hidden properties, but it only hides ...

Every time a user clicks on the map, Leaflet automatically adjusts the center

Currently, I am utilizing leaflet within Vue.js to display an image. I have incorporated custom features such as draggable boxes on the map that can be transformed into rectangle leaflet objects by leaflet. My objective is to be able to click on a rectang ...

Angular utilizes array format to store data in the $scope

I am working on an Angular test application where I am trying to retrieve data from a PHP page into my model. The response comes using the echo json_encode($arr); command in the PHP file and has the format [{"id":"1","name":"first","text":"description"}]. ...

Tips for structuring classes in an Angular project

What is the best approach for handling API responses using classes in various programming languages like TypeScript, JavaScript, Java, or others? Consider an application that requires three resources: Account (API: /account/:id) Car (API: /account/:id/c ...

Numerous points highlighted on the map

As I develop my application, I am working on setting up an event to automatically load data from a CSV excel file for display. My goal is to extract information from the Excel CSV file and use it to populate locations on a Google Map within my application ...

How can you achieve three layers of nested quotes in Dynamic HTML?

Working on an app that utilizes JQuery and JQTouch for iOS. The issue I'm facing involves dynamically generated HTML lists where the user clicks a row that needs to be highlighted. However, achieving this has proven tricky due to nesting 3 sets of quo ...

Vue app experiencing issues with .env file not displaying all characters

My .env file has the following variable defined: VUE_APP_CLIENT_SECRET=$2a$10$tgYzYgMgTsdfLlRFtkd9IeEc2W4v/0EuG1uf05ztQARqhsf3esr9D5Zi When I try to access this variable using process.env.VUE_APP_CLIENT_ID, it only returns "/0EuG1uf05ztQARqhsf3esr9D5 ...

"Encountering a Syntax Error When Using request.post in Dojo Framework on Button Click

Here are three questions to consider: 1) What strategies can be utilized to streamline this code and reduce nesting and quote-related complications? 2) Are there any suggestions for addressing the parsing error mentioned below? I've already tested sep ...

Appwrite error message: Unable to access properties of undefined (looking for 'endpoint')

I am currently working on a project using Appwrite and I have encountered an issue with SDKs. When I use a client-side SDK to interact with the functions of Appwrite Teams, everything works perfectly like this: import { Client, Teams } from "appwrite& ...

Can you explain the distinction between using angular.copy() and simply using an assignment (=) to assign values

When a button is clicked, I want to assign certain values using the event parameter. Here is the code: $scope.update = function(context) { $scope.master = context; }; The $scope.master has been assigned the values of user. Recently, I came across th ...

The android() method could not be located on the root project 'xyz' of type org.gradle.api.Project when passing [before_plugins_] as arguments

Encountering an issue while attempting to run the Nativescript Android application on my device. The error message states: Could not find method android() for arguments [before_plugins_d5qrcua3za3scd760qug60fz6$_run_closure1@5754ca71] on root project &apos ...

What is the best way to implement asynchronous image loading on hover events in React.js?

You may have come across this type of effect before. A good example can be found here - https://codepen.io/anon/pen/GEmOQy However, I am looking to achieve the same effect in React. While I understand that I can use the componentDidMount method for AJAX c ...

Design your very own personalized Show Layout component

Currently, I'm in the process of creating a unique layout component to enhance the design of my Show page. I've encountered some inconsistencies with functionality, and my solution involves utilizing the Material-UI <Grid> component. While ...

Verifying user login on NodeJS through connection from an IIS-hosted website

I am currently upgrading an outdated CMS system and looking to implement a real-time chat feature. The existing CMS operates on IIS, MSSQL, and PHP. The chat feature will be hosted on a separate Linux box running Node.js and Socket.io After successfully ...

I'm having trouble understanding why I can't access the properties of a class within a function that has been passed to an Angular

Currently, I have integrated HTML 5 geolocation into an Angular component: ... export class AngularComponent { ... constructor(private db: DatabaseService) {} // this function is linked to an HTML button logCoords(message, ...

Puppeteer gathers data on page loading - including a comprehensive list of files loaded and their respective sizes

Is it feasible to compile a complete list of all files loaded on a webpage using Google's Puppeteer? This would include scripts, styles (excluding inline), images, videos, and audio, along with their respective sizes. If Puppeteer cannot provide this ...