【问题标题】:Nuxt.js Plugin not found: /tmp/build_fb2cdbad/plugins/heap.jsNuxt.js 插件未找到:/tmp/build_fb2cdbad/plugins/heap.js
【发布时间】:2021-02-13 10:44:01
【问题描述】:

我正在尝试使用 nuxt.config.js 导入插件。但是在构建应用程序时找不到插件。但是当我使用npm run dev 运行应用程序时它可以找到它。我正在使用 nuxt.js 版本:2.14.6。 我的 nuxt.config.js 文件:

export default {
  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    title: 'Trending',
    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: '/logo.jpeg' }
    ]
  },

  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    '@/plugins/heap.js'
  ],

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

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

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
    'cookie-universal-nuxt',
    '@nuxtjs/sentry',
  ],

  sentry: {
    dsn: 'SECRET',
  },

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

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

【问题讨论】:

    标签: javascript vue.js plugins nuxt.js


    【解决方案1】:

    在项目目录的插件文件夹中创建heap.js 并在 nuxt.config.js 中指定模式

    plugins: [
        {src: '~/plugins/something.js', mode: 'server'},
      ],
    

    【讨论】:

      猜你喜欢
      • 2015-03-15
      • 2016-11-27
      • 2018-05-03
      • 1970-01-01
      • 2021-06-20
      • 1970-01-01
      • 2020-05-03
      • 2018-09-29
      • 2019-11-23
      相关资源
      最近更新 更多