无论何时我运行开发服务器都没有错误,但是当我运行npm run generate
时,在构建项目时会发生错误。我不知道错误来自何处以及问题所在的位置。我的代码中没有任何窗口组件。使用npm run dev
运行时工作正常,但是当我执行npm run generate
时会发生此错误
ERROR window is not defined 14:40:27
at a.setWidths (pages/index.js:2254:7)
at un.run (node_modules/vue/dist/vue.runtime.common.prod.js:6:27543)
at sn (node_modules/vue/dist/vue.runtime.common.prod.js:6:25554)
at Array.<anonymous> (node_modules/vue/dist/vue.runtime.common.prod.js:6:12260)
at Wt (node_modules/vue/dist/vue.runtime.common.prod.js:6:11661)
这是我的nuxt.config.js当前版本
import colors from "vuetify/es5/util/colors";
export default {
mode: "universal",
target: "static",
router: {
base: "/"
},
head: {
link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
},
css: [],
plugins: [],
components: true,
buildModules: ["@nuxtjs/vuetify"],
modules: [
"@nuxtjs/axios",
"@nuxtjs/pwa",
"@nuxt/content"
],
pwa: {
manifest: {
name: "My way my love",
short_name: "My way my love",
description: "Personal Website",
icons: [
{
src: "icon.png",
sizes: "360x360",
type: "image/png"
}
],
start_url: "../",
display: "standalone",
background_color: "#ffffff",
theme_color: "#4C8BF4",
lang: "en"
}
},
axios: {},
content: {
markdown: {
prism: {
theme: "prism-themes/themes/prism-vsc-dark-plus.css"
}
}
},
loading: { color: "#4C8BF4" },
vuetify: {
customVariables: ["~/assets/variables.scss"],
theme: {
dark: false,
themes: {
dark: {
primary: colors.blue.darken2,
accent: colors.grey.darken3,
secondary: colors.amber.darken3,
info: colors.teal.lighten1,
warning: colors.amber.base,
error: colors.deepOrange.accent4,
success: colors.green.accent3
}
}
}
},
build: {}
};