Skip to content

Commit 23d5ea9

Browse files
ntwcklngnkzawa
authored andcommitted
Add warning when running start without build (#736)
* add warning when running start without build * run build before start * Revert "run build before start" This reverts commit 171b544. * exit code & dir * dont update yarn.lock * use existsSync * Add some style changes.
1 parent 4fcc551 commit 23d5ea9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bin/next-start

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { resolve } from 'path'
44
import parseArgs from 'minimist'
55
import Server from '../server'
6+
import { existsSync } from 'fs'
67

78
const argv = parseArgs(process.argv.slice(2), {
89
alias: {
@@ -38,6 +39,12 @@ if (argv.help) {
3839
const dir = resolve(argv._[0] || '.')
3940

4041
const srv = new Server({ dir })
42+
43+
if (!existsSync(resolve(dir, '.next'))) {
44+
console.error(`> Could not find the '.next' directory! Try building your app with 'next build' before starting the server.`)
45+
process.exit(1)
46+
}
47+
4148
srv.start(argv.port)
4249
.then(() => {
4350
if (!process.env.NOW) {
@@ -48,3 +55,4 @@ srv.start(argv.port)
4855
console.error(err)
4956
process.exit(1)
5057
})
58+

0 commit comments

Comments
 (0)