npm run build 不起作用,而 npm run dev 起作用,NuxtJS

时间:2021-07-10 13:30:51

标签: javascript vue.js nuxt.js

我正在尝试从我一直在处理的 nuxtJs 项目中导出 dist 文件夹。 当我使用命令在本地机器上运行项目时,一切正常 npm 运行开发 但是当我尝试跑步时 npm 运行生成 要么 npm 运行构建 出现下面的错误

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

}

可能导致问题的原因是什么?

1 个答案:

答案 0 :(得分:0)

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

 // Auto import components: https://go.nuxtjs.dev/config-components
 components: false,
相关问题