nuxt.js - 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'
}
}
}
解决方案
推荐阅读
- java - 使用 spark 进行 hdfs 文件流式传输
- node.js - Angular 从 JSON 获取数据到模型并列出它
- django - 如何在 django 中创建一个日志数据库来记录创建、更新或删除对象的用户?
- sql - 有没有更好的方法来优先考虑子查询而不是使用 TOP?
- javascript - FullCalendar:在调用 RestAPI 调用后将 JSON 数据与 initialEvents 绑定
- flutter - 如何用未来 Http Post 的结果显示 Snackbar?
- python - Python数据框操作
- windows - 无法启动 Minikube - 使用 HyperV
- c# - 指定 B2C 策略(在 C# 中)的顺序是否重要?
- database - 如何使用聚合在 mongodb 中获取选定字段的值大小