File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22import { resolve , join } from 'path'
33import parseArgs from 'minimist'
4- import { existsSync , readFileSync } from 'fs'
4+ import { existsSync } from 'fs'
55import Server from '../server'
66import { printAndExit } from '../lib/utils'
77
@@ -65,9 +65,14 @@ srv.start(argv.port, argv.hostname)
6565 const pkgAppPath = require ( 'find-up' ) . sync ( 'package.json' , {
6666 cwd : dir
6767 } )
68- const appPackage = JSON . parse ( readFileSync ( pkgAppPath , 'utf8' ) )
69- const nextScript = Object . entries ( appPackage . scripts ) . find ( scriptLine => scriptLine [ 1 ] === 'next' )
70- if ( nextScript ) errorMessage += `\nUse \`npm run ${ nextScript [ 0 ] } -- -p <some other port>\`.`
68+ const appPackage = require ( pkgAppPath )
69+ if ( appPackage . scripts ) {
70+ const nextScript = Object . entries ( appPackage . scripts ) . find ( scriptLine => scriptLine [ 1 ] === 'next' )
71+ if ( nextScript ) {
72+ errorMessage += `\nUse \`npm run ${ nextScript [ 0 ] } -- -p <some other port>\`.`
73+ }
74+ }
75+
7176 console . error ( errorMessage )
7277 } else {
7378 console . error ( err )
You can’t perform that action at this time.
0 commit comments