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/.`);
7171 options = require ( "./utils/convert-argv" ) ( argv ) ;
7272 } catch ( err ) {
7373 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 = "" ;
7677
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` ;
8181
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+ }
8690 }
8791
8892 if ( err . name !== "ValidationError" ) {
You can’t perform that action at this time.
0 commit comments