@@ -108,7 +108,7 @@ export default async function start(argvs: StartArgs) {
108
108
// Keep `evalSourceMapMiddleware`
109
109
// middlewares before `redirectServedPath` otherwise will not have any effect
110
110
// This lets us fetch source contents from webpack for the error overlay
111
- devServer . app . use ( evalSourceMapMiddleware ( devServer ) ) ;
111
+ devServer . app && devServer . app . use ( evalSourceMapMiddleware ( devServer ) ) ;
112
112
if ( fs . existsSync ( paths . proxySetup ) ) {
113
113
// This registers user provided middleware for proxy reasons
114
114
require ( paths . proxySetup ) ( devServer . app ) ;
@@ -119,14 +119,14 @@ export default async function start(argvs: StartArgs) {
119
119
}
120
120
121
121
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
122
- devServer . app . use ( redirectServedPath ( paths . publicUrlOrPath ) ) ;
122
+ devServer . app && devServer . app . use ( redirectServedPath ( paths . publicUrlOrPath ) ) ;
123
123
124
124
// This service worker file is effectively a 'no-op' that will reset any
125
125
// previous service worker registered for the same host:port combination.
126
126
// We do this in development to avoid hitting the production cache if
127
127
// it used the same host and port.
128
128
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
129
- devServer . app . use ( noopServiceWorkerMiddleware ( paths . publicUrlOrPath ) ) ;
129
+ devServer . app && devServer . app . use ( noopServiceWorkerMiddleware ( paths . publicUrlOrPath ) ) ;
130
130
const mds = setupMiddlewares ? setupMiddlewares ( middlewares , devServer ) : middlewares ;
131
131
return staticDocSetupMiddlewares ( mds , devServer , { ...argvs , paths, config : webpackConf } ) ;
132
132
} ;
@@ -142,7 +142,7 @@ export default async function start(argvs: StartArgs) {
142
142
console . log ( '❌ KKT:\x1b[31;1mERR\x1b[0m:' , err ) ;
143
143
return ;
144
144
}
145
- if ( stats . hasErrors ( ) ) {
145
+ if ( stats && stats . hasErrors ( ) ) {
146
146
clearConsole ( ) ;
147
147
console . log ( `❌ KKT:\x1b[31;1mERR\x1b[0m: \x1b[35;1m${ today ( ) } \x1b[0m\n` , stats . toString ( ) ) ;
148
148
return ;
@@ -156,7 +156,7 @@ export default async function start(argvs: StartArgs) {
156
156
require ( `${ reactScripts } /scripts/start` ) ;
157
157
}
158
158
} catch ( error ) {
159
- const message = error && error . message ? error . message : '' ;
159
+ const message = error && error instanceof Error && error . message ? error . message : '' ;
160
160
console . log ( '\x1b[31;1m KKT:START:ERROR: \x1b[0m\n' , error ) ;
161
161
new Error ( `KKT:START:ERROR: \n ${ message } ` ) ;
162
162
process . exit ( 1 ) ;
0 commit comments