@@ -149,33 +149,33 @@ private function diagnoseAndReportNpmFailure(string $path, SymfonyStyle $io, \Ex
149149 $ io ->error ('Failed to install node modules. ' );
150150 $ io ->newLine ();
151151
152- // Check 1: npm availability
152+ // Check 1: package.json validity (project-specific, quick check)
153+ if (!$ this ->isPackageJsonValid ($ path )) {
154+ $ io ->error ('package.json is missing or contains invalid JSON. ' );
155+ $ io ->writeln ('<fg=yellow>Fix:</> ' );
156+ $ sanitizedPath = preg_replace ('/[[:cntrl:]]/ ' , '' , $ path );
157+ $ io ->writeln (
158+ ' Verify package.json exists at: ' . $ sanitizedPath . '/package.json '
159+ );
160+ return ;
161+ }
162+
163+ // Check 2: npm availability
153164 if (!$ this ->isCommandAvailable ('npm ' )) {
154165 $ io ->error ('npm is not installed or not available in PATH. ' );
155166 $ io ->writeln ('<fg=yellow>Fix:</> ' );
156167 $ io ->writeln (' Install Node.js and npm: https://nodejs.org/ ' );
157168 return ;
158169 }
159170
160- // Check 2 : node availability
171+ // Check 3 : node availability
161172 if (!$ this ->isCommandAvailable ('node ' )) {
162173 $ io ->error ('Node.js is not installed or not available in PATH. ' );
163174 $ io ->writeln ('<fg=yellow>Fix:</> ' );
164175 $ io ->writeln (' Install Node.js: https://nodejs.org/ ' );
165176 return ;
166177 }
167178
168- // Check 3: package.json validity
169- if (!$ this ->isPackageJsonValid ($ path )) {
170- $ io ->error ('package.json is missing or contains invalid JSON. ' );
171- $ io ->writeln ('<fg=yellow>Fix:</> ' );
172- $ sanitizedPath = preg_replace ('/[[:cntrl:]]/ ' , '' , $ path );
173- $ io ->writeln (
174- ' Verify package.json exists at: ' . $ sanitizedPath . '/package.json '
175- );
176- return ;
177- }
178-
179179 // Check 4: package-lock.json corruption
180180 if ($ this ->fileDriver ->isExists ($ path . '/package-lock.json ' )) {
181181 if (!$ this ->isPackageLockValid ($ path )) {
0 commit comments