首页 > 解决方案 > nuxt 生成的 dist 文件返回 net::ERR_FILE_NOT_FOUND

问题描述

我正在尝试生成我的 nuxtjs 应用程序的静态站点,然后将其上传到 s3 存储桶以提供服务。

我跑了npm run generate,它生成了dist文件夹。

我将dist文件夹复制到 s3 存储桶s3.exampleaws.com/webapp/latest

现在主index.html文件应该在这里s3.exampleaws.com/webapp/latest/index.html

当我访问此页面时,什么都看不到,在控制台上,我收到以下错误:

4 获取文件:///_nuxt/f69388b45d6b2e9cc542.js 网络::ERR_FILE_NOT_FOUND

即使我在浏览器中打开index.html文件dist夹中的文件,它仍然显示相同的错误。

有没有办法在浏览器上显示网站?

我的nuxt.config.js文件如下所示:


export default {
  mode: 'spa',
  /*
  ** Headers of the page
  */
  head: {
    title: process.env.npm_package_name || '',
    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' }
    ]
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
    '~/assets/css/tailwind.css',
    '~/assets/css/all.css'
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js modules
  */
  modules: [
    // Doc: https://axios.nuxtjs.org/usage
    '@nuxtjs/axios',
    '@nuxtjs/pwa',
    '@nuxtjs/proxy',
    '@nuxtjs/toast'
  ],
  /*
  ** Axios module configuration
  ** See https://axios.nuxtjs.org/options
  */
  axios: {
  },
  /*
  ** Build configuration
  */
  build: {
    postcss: {
      plugins: {
        tailwindcss: './tailwind.config.js'
      }
    },
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      config.output.globalObject = 'this'
    }
  }
}

标签: nuxt.js

解决方案


推荐阅读