mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
nuxt-start: throw error if nuxt build
not called
This commit is contained in:
parent
faa8db4701
commit
9d1765ae91
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user