File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -71,18 +71,22 @@ For more information, see https://webpack.js.org/api/cli/.`);
71
71
options = require ( "./utils/convert-argv" ) ( argv ) ;
72
72
} catch ( err ) {
73
73
if ( err . code === "MODULE_NOT_FOUND" ) {
74
- let errorMessage =
75
- "\n\u001b[31mwebpack not installed, consider installing it using \n\u001b[32mnpm install --save-dev webpack\n" ;
74
+ const moduleName = err . message . split ( "'" ) [ 1 ] ;
75
+ let instructions = "" ;
76
+ let errorMessage = "" ;
76
77
77
- if ( process . env . npm_execpath !== undefined && process . env . npm_execpath . includes ( "yarn" ) ) {
78
- errorMessage =
79
- "\n\u001b[31mwebpack not installed, consider installing it using \n\u001b[32myarn add webpack --dev\n" ;
80
- }
78
+ if ( moduleName === "webpack" ) {
79
+ errorMessage = `\n${ moduleName } not installed` ;
80
+ instructions = `Install webpack to start bundling: \u001b[32m\n $ npm install --save-dev ${ moduleName } \n` ;
81
81
82
- console . error ( errorMessage ) ;
83
- Error . stackTraceLimit = 1 ;
84
- process . exitCode = 1 ;
85
- return ;
82
+ if ( process . env . npm_execpath !== undefined && process . env . npm_execpath . includes ( "yarn" ) ) {
83
+ instructions = `Install webpack to start bundling: \u001b[32m\n $ yarn add ${ moduleName } --dev\n` ;
84
+ }
85
+ Error . stackTraceLimit = 1 ;
86
+ console . error ( `${ errorMessage } \n\n${ instructions } ` ) ;
87
+ process . exitCode = 1 ;
88
+ return ;
89
+ }
86
90
}
87
91
88
92
if ( err . name !== "ValidationError" ) {
You can’t perform that action at this time.
0 commit comments