npm运行构建不工作,而npm运行开发不工作,nuxtjs

d4so4syb  于 2021-09-23  发布在  Java
关注(0)|答案(1)|浏览(373)

我正试图从一个我一直在做的nuxtjs项目中导出dist文件夹。当我使用命令npm run dev在本地机器上运行项目时,一切都正常,但是当我尝试运行npm run generate或npm run build时,下面的错误就会出现

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

这是我的nuxt.config.js文件:

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: {
  }

}

什么可能导致问题?

lb3vh1jj

lb3vh1jj1#

我只是不知道发生了什么,但由于在安装和加载组件时出现了问题,因此更改了与中组件的自动导入相关的属性的布尔值 nuxt.config.js 为了解决我的问题。

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

相关问题