{"record":{"id":"83b97bcc9677431f","repo":"angular/angular-cli","slug":"warning-formatting-of-files-failed-with-the-follo-83b97b","errorCode":null,"errorMessage":"WARNING: Formatting of files failed with the following error: ${error.message}","messagePattern":"WARNING: Formatting of files failed with the following error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/update/utilities/migration.ts","lineNumber":237,"sourceCode":"    switch (files.size) {\n      case 0:\n        modifiedFilesText = 'No changes made';\n        break;\n      case 1:\n        modifiedFilesText = '1 file modified';\n        break;\n      default:\n        modifiedFilesText = `${files.size} files modified`;\n        break;\n    }\n\n    if (files.size) {\n      try {\n        await formatFiles(process.cwd(), files);\n      } catch (error) {\n        assertIsError(error);\n\n        logger.warn(\n          `WARNING: Formatting of files failed with the following error: ${error.message}`,\n        );\n      }\n    }\n\n    logger.info(`  Migration completed (${modifiedFilesText}).`);\n\n    // Commit migration\n    if (commit) {\n      const commitPrefix = `${packageName} migration - ${migration.name}`;\n      const commitMessage = migration.description\n        ? `${commitPrefix}\\n\\n${migration.description}`\n        : commitPrefix;\n      const committed = commitChanges(logger, commitMessage);\n      if (!committed) {\n        // Failed to commit, something went wrong. Abort the update.\n        return 1;\n      }","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/update/utilities/migration.ts#L219-L255","documentation":"After running package migrations, `ng update` attempts to format all touched files (prettier). If formatFiles throws, the migration itself is still complete and successful; this warning reports the formatting failure with the underlying error message.","triggerScenarios":"`formatFiles(process.cwd(), files)` throws — e.g. a file with syntax prettier cannot parse, unreadable file permissions, or a prettier configuration error in the workspace.","commonSituations":"Migrations touching generated or malformed code prettier can't parse; a broken .prettierrc; files locked by an editor/AV on Windows; low disk space.","solutions":["Read the inner error.message and fix the specific file it complains about (usually a syntax issue).","Run prettier manually on the affected files to see the full error.","Check/repair your prettier config (.prettierrc, overrides).","Ensure files are writable and not locked; then rerun the migration or format manually."],"exampleFix":"// before (.prettierrc)\n{ \"parser\": \"not-a-real-parser\" }\n// after\n{ \"printWidth\": 100 }","handlingStrategy":"try-catch","validationCode":"const filesArr = [...files]; const bad = filesArr.filter(f => !fs.existsSync(f) || !fs.accessSync(f, fs.constants.W_OK)); if (bad.length) throw new Error(`unwritable: ${bad}`);","typeGuard":"function assertIsError(e: unknown): asserts e is Error { if (!(e instanceof Error)) throw e; }","tryCatchPattern":"try { await formatFiles(process.cwd(), files); } catch (error) { assertIsError(error); logger.warn(`WARNING: Formatting of files failed with the following error: ${error.message}`); }","preventionTips":["Keep prettier config valid and minimal.","Fix syntax errors in generated/migrated files before formatting.","Ensure migrated files are writable and not locked.","Run prettier manually on the workspace regularly to catch issues early."],"tags":["prettier","formatting","ng-update","migration"],"backgroundTag":"code-formatting-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}