pbakaus/impeccable · error · Error
config.insertBefore or config.insertAfter (string) required
Error message
config.insertBefore or config.insertAfter (string) required
What it means
Sixth validateConfig() check: at least one of cfg.insertBefore or cfg.insertAfter must be a string. These are the anchor selectors used by insertTag() to place the live <script>; without one the injector has no insertion point. Both may be strings (insertBefore wins), but neither being a string is fatal.
Source
Thrown at plugin/skills/impeccable/scripts/live-inject.mjs:466
function validateConfig(cfg) {
if (!cfg || typeof cfg !== 'object') throw new Error('config.json must be an object');
if (!Array.isArray(cfg.files) || cfg.files.length === 0) {
throw new Error('config.files (non-empty string array) required');
}
if (!cfg.files.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.files must contain only non-empty strings');
}
if (cfg.exclude !== undefined) {
if (!Array.isArray(cfg.exclude)) {
throw new Error('config.exclude, if present, must be a string array');
}
if (!cfg.exclude.every((f) => typeof f === 'string' && f.length > 0)) {
throw new Error('config.exclude must contain only non-empty strings');
}
}
if (typeof cfg.insertBefore !== 'string' && typeof cfg.insertAfter !== 'string') {
throw new Error('config.insertBefore or config.insertAfter (string) required');
}
if (cfg.commentSyntax !== 'html' && cfg.commentSyntax !== 'jsx') {
throw new Error("config.commentSyntax must be 'html' or 'jsx'");
}
if (cfg.cspChecked !== undefined && typeof cfg.cspChecked !== 'boolean') {
throw new Error("config.cspChecked, if present, must be a boolean");
}
}
// ---------------------------------------------------------------------------
// Auto-execute
// ---------------------------------------------------------------------------
const _running = process.argv[1];
if (_running?.endsWith('live-inject.mjs') || _running?.endsWith('live-inject.mjs/')) {
enterLiveRoot();
injectCli();
}View on GitHub (pinned to d14711ae3d)
Solutions
- Set insertBefore to a string marker that exists in your HTML (e.g. '</head>' or '</body>') or insertAfter to an opening tag (e.g. '<body>').
- Re-run live setup so the wizard detects the anchor from your entry-point file.
- If using a framework adapter (Nuxt etc.) the adapter supplies its own insertion logic, but validateConfig still requires one of the two keys as a string.
- Validate with `node live-inject.mjs --check`.
Example fix
// before
{ "files": ["index.html"], "commentSyntax": "html" }
// after
{ "files": ["index.html"], "commentSyntax": "html", "insertBefore": "</head>" } Defensive patterns
Strategy: validation
Validate before calling
function hasInsertAnchor(cfg) {
return typeof cfg?.insertBefore === 'string' || typeof cfg?.insertAfter === 'string';
}
if (!hasInsertAnchor(cfg)) {
throw new Error('Provide config.insertBefore or config.insertAfter as a string anchor.');
} Type guard
/** True when at least one anchor is a string. */
function hasAnchor(cfg) {
return typeof cfg?.insertBefore === 'string' || typeof cfg?.insertAfter === 'string';
} Try / catch
try {
validateConfig(cfg);
} catch (err) {
if (/insertBefore or config\.insertAfter/.test(err.message)) {
cfg.insertBefore = '</head>';
validateConfig(cfg);
}
throw err;
} Prevention
- Always set insertBefore (e.g. '</head>') or insertAfter (e.g. '<body>') as a string anchor.
- Re-run live setup so the wizard detects an anchor from your entry-point file.
- Even with a framework adapter, keep one anchor string to satisfy validation.
When it happens
Trigger: Both keys absent; both null; one present but as a non-string (e.g. a regex or array); only commentSyntax and files provided. The injector needs a literal string like '</head>' or '<body>' to locate the tag insertion point.
Common situations: Setup wizard didn't detect an anchor and left both blank; user removed the anchor keys thinking the injector would default; config copied from a project whose anchors differed; value accidentally set to a number or object.
Related errors
- config.json must be an object
- config.files (non-empty string array) required
- config.files must contain only non-empty strings
- config.exclude, if present, must be a string array
- config.exclude must contain only non-empty strings
AI-assisted analysis of pbakaus/impeccable@d14711ae3d (2026-08-13).
Data as JSON: /api/errors/5fa5d2702edc0330.
Report an issue: GitHub.