Apps Script Rhino → V8 error guides
The exact error V8 throws, why Rhino allowed it, and the fix.
- Apps Script Rhino → V8 migration checklistRhino was retired in 2026. Step-by-step checklist to migrate Google Apps Script to V8: enable runtimeVersion V8, fix syntax errors, behaviour changes, redeploy versions.
- Fix "SyntaxError: Unexpected identifier 'each'" (for each…in) in Apps Script V8Apps Script fails with SyntaxError Unexpected identifier 'each' after switching to V8. Replace Rhino for each (x in obj) loops with for…of or Object.values.
- Fix "Unexpected token 'if'" in catch (conditional catch) on Apps Script V8Rhino allowed catch (e if e instanceof TypeError). V8 throws SyntaxError Unexpected token 'if'. Move the condition into a single catch block.
- Fix "XML is not defined" and "Unexpected token '<'" (E4X) on Apps Script V8E4X XML literals, new XML(), .@attr and ..descendant don't exist in V8. Rewrite Rhino E4X code with XmlService.parse, getChild, getAttribute.
- Fix "Unexpected token 'class'" / "Unexpected reserved word" in Apps Script V8Rhino let you name variables or functions class, import, export or enum. V8 rejects them. Rename the identifier and the menu/trigger strings that reference it.
- Fix "TypeError: Assignment to constant variable." in Apps Script V8Rhino silently ignored reassigning a const; V8 throws TypeError Assignment to constant variable. Find the reassignments and switch to let or var.
- Fix "Identifier 'X' has already been declared" across .gs files in V8All .gs files share one global scope in V8. The same top-level const, let or class in two files throws Identifier 'X' has already been declared.
- Fix getYear() returning 126 instead of 2026 in Apps Script V8After moving Apps Script to V8, Date.getYear() returns the year minus 1900 (126, not 2026). Replace getYear with getFullYear to fix wrong years in sheets and emails.
- toLocaleDateString() output changed after V8 migration — how to keep the old formatOn V8, toLocaleDateString(), toLocaleString() and toLocaleTimeString() use short formats and honour locale arguments. Pin dates with Utilities.formatDate.
- Fix "ScriptProperties is not defined" and other removed Rhino-era servicesScriptProperties, UserProperties, Utilities.jsonParse, UiApp, DocsList and ScriptDb were removed. Replace them with PropertiesService, JSON, HtmlService and DriveApp.
- Fix "toSource is not a function" and "uneval is not defined" on Apps Script V8Object.prototype.toSource() and uneval() existed in Rhino but not V8. Replace them with JSON.stringify for logging and caching data.
- Fix "StopIteration is not defined" and __iterator__ on Apps Script V8Rhino's __iterator__, Iterator() and StopIteration don't exist on V8. Replace them with Symbol.iterator, function* generators and for…of.
- Fix expression closures `function(x) x * x` and `let (…)` blocks on V8Rhino accepted function(x) x * x and let (a = 1) { } blocks. V8 throws SyntaxError. Convert them to arrow functions and normal block-scoped let.
- Fix "java is not defined" and "Packages is not defined" on Apps Script V8Rhino-era scripts that touched java.lang, java.util or Packages fail on V8 with java is not defined. Use Utilities, UrlFetchApp and plain JavaScript instead.
- error.lineNumber is undefined on Apps Script V8 — log e.stack insteadV8 Error objects have no lineNumber or fileName, so Rhino-era error logging prints undefined. Log e.stack, which includes function, file and line.
- setValue(undefined) clears cells and JSON.stringify(enum) changed on V8On Rhino setValue(undefined) wrote the text "undefined" and JSON.stringify of enums returned {}. On V8 undefined clears the cell and enums stringify to their name.
- Global `this`, `instanceof` in libraries and prototype changes on Apps Script V8On V8, Object.keys(this) lists every Apps Script service, instanceof fails for objects passed into libraries, and Array.prototype additions leak into for…in loops.
- new Date("…") gives Invalid Date or the wrong day on Apps Script V8Date strings parse differently on V8. "2026-01-05" is UTC midnight (the previous day in US time zones) and non-ISO formats are implementation-defined. Parse explicitly.
- Utilities.formatDate "YYYY" shows the wrong year — use "yyyy-MM-dd"Utilities.formatDate with 'YYYY-MM-DD' prints next year in late December and day-of-year for DD. Use yyyy and dd. Common bug found when migrating Rhino scripts.