File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
import { resolve , join } from 'path'
3
3
import parseArgs from 'minimist'
4
- import { existsSync , readFileSync } from 'fs'
4
+ import { existsSync } from 'fs'
5
5
import Server from '../server'
6
6
import { printAndExit } from '../lib/utils'
7
7
@@ -65,9 +65,14 @@ srv.start(argv.port, argv.hostname)
65
65
const pkgAppPath = require ( 'find-up' ) . sync ( 'package.json' , {
66
66
cwd : dir
67
67
} )
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
+
71
76
console . error ( errorMessage )
72
77
} else {
73
78
console . error ( err )
You can’t perform that action at this time.
0 commit comments