From 29ebccaa6551a82f2523e7b526c7f1057c795517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 8 May 2020 13:55:39 +0200 Subject: [PATCH] fix(generator): avoid error if nuxt/config.js does not exists in buildDir (#7332) --- packages/generator/src/generator.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/generator/src/generator.js b/packages/generator/src/generator.js index b10a06344e..1d78511fd2 100644 --- a/packages/generator/src/generator.js +++ b/packages/generator/src/generator.js @@ -73,7 +73,7 @@ export default class Generator { ) } const config = this.getBuildConfig() - if (config.target !== TARGETS.static) { + if (!config || config.target !== TARGETS.static) { throw new Error( `In order to use \`nuxt export\`, you need to run \`nuxt build --target static\`` ) @@ -128,7 +128,11 @@ export default class Generator { } getBuildConfig () { - return require(path.join(this.options.buildDir, 'nuxt/config.json')) + try { + return require(path.join(this.options.buildDir, 'nuxt/config.json')) + } catch (err) { + return null + } } getAppRoutes () {