npm run build does not work while npm run dev does , NuxtJS

Viewed 661

I'm trying to export the dist folder from a nuxtJs project i'v been working on . everything works fine when i run the project on my local machine with the command npm run dev but when i try to run npm run generate or npm run build the error bellow shows up

ERROR in ./layouts/default.vue 22:83
Module parse failed: Unexpected token (22:83)
File was processed with these loaders:
 * ./node_modules/@nuxt/components/dist/loader.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| 
| /* nuxt-component-imports */
> installComponents(component, {OurHeader: require('/home/adnane/Desktop/code/adnane's projects/broker-interface-main-5/broker-interface-main/components/OurHeader.vue').default,OurFooter: require('/home/adnane/Desktop/code/adnane's projects/broker-interface-main-5/broker-interface-main/components/OurFooter.vue').default})
| 
 @ ./.nuxt/App.js 27:0-47 29:32-41
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/client.js

ERROR in ./pages/plans-packages.vue 23:84
Module parse failed: Unexpected token (23:84)
File was processed with these loaders:
 * ./node_modules/@nuxt/components/dist/loader.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| 
| /* nuxt-component-imports */
> installComponents(component, {PlansCards: require('/home/adnane/Desktop/code/adnane's projects/broker-interface-main-5/broker-interface-main/components/Plans/PlansCards.vue').default,PlansComparison: require('/home/adnane/Desktop/code/adnane's projects/broker-interface-main-5/broker-interface-main/components/Plans/PlansComparison.vue').default})
| 
 @ ./.nuxt/router.js 107:24-109:3
 @ ./.nuxt/index.js
 @ ./.nuxt/client.js
 @ multi ./node_modules/@nuxt/components/lib/installComponents.js ./.nuxt/client.js

and here's my nuxt.config.js file :

export default {
  target: 'static',
  loading: false,
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    titleTemplate: "وسيط | %s",
    htmlAttrs: {
      lang: 'ar',
      dir: 'rtl'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
    ],
    script: [
      {
        src: "https://cdnjs.cloudflare.com/ajax/libs/mixitup/3.3.1/mixitup.min.js",
        body: true,
        async: true,
        defer: true,
      },
      {
        src: "https://unpkg.com/aos@2.3.1/dist/aos.js",
        body: true,
      },
    ],
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
    '~/assets/styles/global.scss'
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
    { src: '~/plugins/bootstrap.js', mode: 'client' },
    { src: '~/plugins/VueCarousel.js', mode: 'client' },
    { src: '~/plugins/SweetAlert.js', mode: 'client' },
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {},

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
  }

}

what may cause the problem ?

1 Answers

I just don't know what happened but since there was a problem in installing the components and loading them , changing the boolean value of the attribute related to The Auto import of the components in nuxt.config.js to false fixed my problem .

 // Auto import components: https://go.nuxtjs.dev/config-components
 components: false,
Related