File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -71,15 +71,23 @@ 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" ;
78
+ if ( moduleName === "webpack" ) {
79
+ errorMessage = `\n\u001b[31m${ moduleName } not installed` ;
80
+ instructions = `Consider installing it using " npm install --save-dev ${ moduleName } "\n` ;
81
+
82
+ if ( process . env . npm_execpath !== undefined && process . env . npm_execpath . includes ( "yarn" ) ) {
83
+ instructions = `Consider installing it using " yarn add ${ moduleName } --dev "\n` ;
84
+ }
85
+ } else {
86
+ errorMessage = `\n\u001b[31mModule ${ moduleName } is not found but is imported in configuration` ;
87
+ instructions = `If ${ moduleName } is a package, install it using a package manager\n` ;
80
88
}
81
89
82
- console . error ( errorMessage ) ;
90
+ console . error ( ` ${ errorMessage } \n\n\u001b[32mTIP: ${ instructions } ` ) ;
83
91
Error . stackTraceLimit = 1 ;
84
92
process . exitCode = 1 ;
85
93
return ;
You can’t perform that action at this time.
0 commit comments