Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/Service/NodePackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,33 @@ private function diagnoseAndReportNpmFailure(string $path, SymfonyStyle $io, \Ex
$io->error('Failed to install node modules.');
$io->newLine();

// Check 1: npm availability
// Check 1: package.json validity (project-specific, quick check)
if (!$this->isPackageJsonValid($path)) {
$io->error('package.json is missing or contains invalid JSON.');
$io->writeln('<fg=yellow>Fix:</>');
$sanitizedPath = preg_replace('/[[:cntrl:]]/', '', $path);
$io->writeln(
' Verify package.json exists at: ' . $sanitizedPath . '/package.json'
);
return;
}

// Check 2: npm availability
if (!$this->isCommandAvailable('npm')) {
$io->error('npm is not installed or not available in PATH.');
$io->writeln('<fg=yellow>Fix:</>');
$io->writeln(' Install Node.js and npm: https://nodejs.org/');
return;
}

// Check 2: node availability
// Check 3: node availability
if (!$this->isCommandAvailable('node')) {
$io->error('Node.js is not installed or not available in PATH.');
$io->writeln('<fg=yellow>Fix:</>');
$io->writeln(' Install Node.js: https://nodejs.org/');
return;
}

// Check 3: package.json validity
if (!$this->isPackageJsonValid($path)) {
$io->error('package.json is missing or contains invalid JSON.');
$io->writeln('<fg=yellow>Fix:</>');
$sanitizedPath = preg_replace('/[[:cntrl:]]/', '', $path);
$io->writeln(
' Verify package.json exists at: ' . $sanitizedPath . '/package.json'
);
return;
}

// Check 4: package-lock.json corruption
if ($this->fileDriver->isExists($path . '/package-lock.json')) {
if (!$this->isPackageLockValid($path)) {
Expand Down
Loading