diff --git a/bin/next-start b/bin/next-start index 85d9eb81..f4100efc 100755 --- a/bin/next-start +++ b/bin/next-start @@ -3,6 +3,7 @@ import { resolve } from 'path' import parseArgs from 'minimist' import Server from '../server' +import { existsSync } from 'fs' const argv = parseArgs(process.argv.slice(2), { alias: { @@ -38,6 +39,12 @@ if (argv.help) { const dir = resolve(argv._[0] || '.') const srv = new Server({ dir }) + +if (!existsSync(resolve(dir, '.next'))) { + console.error(`> Could not find the '.next' directory! Try building your app with 'next build' before starting the server.`) + process.exit(1) +} + srv.start(argv.port) .then(() => { if (!process.env.NOW) { @@ -48,3 +55,4 @@ srv.start(argv.port) console.error(err) process.exit(1) }) +