mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
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 171b54489df7b6c3ebd0d9d65578acf89d4daa12. * exit code & dir * dont update yarn.lock * use existsSync * Add some style changes.
This commit is contained in:
parent
4fcc551fb4
commit
23d5ea9164
|
@ -3,6 +3,7 @@
|
||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import parseArgs from 'minimist'
|
import parseArgs from 'minimist'
|
||||||
import Server from '../server'
|
import Server from '../server'
|
||||||
|
import { existsSync } from 'fs'
|
||||||
|
|
||||||
const argv = parseArgs(process.argv.slice(2), {
|
const argv = parseArgs(process.argv.slice(2), {
|
||||||
alias: {
|
alias: {
|
||||||
|
@ -38,6 +39,12 @@ if (argv.help) {
|
||||||
const dir = resolve(argv._[0] || '.')
|
const dir = resolve(argv._[0] || '.')
|
||||||
|
|
||||||
const srv = new Server({ dir })
|
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)
|
srv.start(argv.port)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (!process.env.NOW) {
|
if (!process.env.NOW) {
|
||||||
|
@ -48,3 +55,4 @@ srv.start(argv.port)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue