From 9d1765ae916de1e39184cba71300ff45f0823cd1 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 16 Jun 2017 18:34:40 +0430 Subject: [PATCH] nuxt-start: throw error if `nuxt build` not called --- bin/nuxt-start | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/nuxt-start b/bin/nuxt-start index 34c73f6a72..c1ad090ba0 100755 --- a/bin/nuxt-start +++ b/bin/nuxt-start @@ -3,7 +3,7 @@ const fs = require('fs') const parseArgs = require('minimist') const { Nuxt, Server } = require('../') -const resolve = require('path').resolve +const { join, resolve } = require('path') const argv = parseArgs(process.argv.slice(2), { alias: { @@ -55,6 +55,13 @@ if (typeof options.rootDir !== 'string') { } options.dev = false // Force production mode (no webpack middleware called) +// Check if project is built for production +const distDir = join(options.rootDir, options.buildDir || '.nuxt', 'dist' ) +if (!fs.existsSync(join(distDir,'server-bundle.json'))) { + console.error('> No build files found, please run `nuxt build` before launching `nuxt start`') // eslint-disable-line no-console + process.exit(1) +} + const nuxt = new Nuxt(options) const port = argv.port || process.env.PORT || process.env.npm_package_config_nuxt_port const host = argv.hostname || process.env.HOST || process.env.npm_package_config_nuxt_host