{"record":{"id":"7b81bc981d23e2b7","repo":"vercel/next.js","slug":"unterminated-string","errorCode":null,"errorMessage":"Unterminated string","messagePattern":"Unterminated string","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/utils.ts","lineNumber":111,"sourceCode":"    // If we find a quote, we should toggle the string flag.\n    else if (char === '\"') {\n      isInString = !isInString\n      continue\n    }\n\n    // If we're starting a new argument, we should add it to the array.\n    if (willStartNewArg) {\n      args.push(char)\n      willStartNewArg = false\n    }\n    // Otherwise, add it to the last argument.\n    else {\n      args[args.length - 1] += char\n    }\n  }\n\n  if (isInString) {\n    throw new Error('Unterminated string')\n  }\n\n  return args\n}\n\n/**\n * Get the node options from the environment variable `NODE_OPTIONS` and returns\n * them as an array of strings.\n *\n * @returns An array of strings with the node options.\n */\nexport const getNodeOptionsArgs = () => {\n  if (!process.env.NODE_OPTIONS) return []\n\n  return tokenizeArgs(process.env.NODE_OPTIONS)\n}\n\n/**","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/packages/next/src/server/lib/utils.ts#L93-L129","documentation":"Thrown by tokenizeArgs when the args string finishes with an odd number of double-quote characters, meaning a quoted value was opened but never closed. The tokenizer tracks isInString and rejects an unbalanced quote at end of input.","triggerScenarios":"NODE_OPTIONS contains a value with an opening quote but no closing quote, e.g. NODE_OPTIONS='--title=\"my app'. After the loop isInString is still true.","commonSituations":"Shell quoting mistakes in NODE_OPTIONS, a quote accidentally stripped by variable expansion, or copy-pasting a value that lost its closing quote.","solutions":["Count the double-quotes in NODE_OPTIONS and ensure they are balanced (even count).","Properly close every opened quote, e.g. change --title=\"app to --title=\"app\".","If the value has no spaces, remove the quotes entirely."],"exampleFix":"# before: unclosed quote\nexport NODE_OPTIONS='--title=\"my app'\n\n# after: balanced quotes\nexport NODE_OPTIONS='--title=\"my app\"'","handlingStrategy":"validation","validationCode":"function hasBalancedQuotes(input: string): boolean {\n  return (input.match(/\"/g) || []).length % 2 === 0\n}","typeGuard":"function hasBalancedQuotes(input: string): boolean {\n  return (input.match(/\"/g) || []).length % 2 === 0\n}","tryCatchPattern":"try {\n  tokenizeArgs(process.env.NODE_OPTIONS || '')\n} catch (e) {\n  if (e.message === 'Unterminated string') {\n    console.error('NODE_OPTIONS has an unbalanced quote')\n    process.exit(1)\n  }\n}","preventionTips":["Ensure every opening quote in NODE_OPTIONS has a matching close.","Count quotes when constructing NODE_OPTIONS in scripts.","Drop quotes entirely for values without spaces."],"tags":["node-options","cli","env","parsing"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}