- Non riesco ad avviare un progetto pulito. Ho errori persistenti di compilazione (Parsing ecmascript source code failed) anche dopo la correzione automatica di Gemini e dopo aver pulito la cache. Sembra un bug della cache di compilazione del server.
Hi Roberto,
You’re right — hitting parsing errors when starting from what should be a clean project is frustrating, especially when the tool says “auto-fix complete” but the error persists. I’ve seen this happen when the AI-generated code (especially from Gemini) uses a newer ECMAScript syntax than the build environment supports, or when the cache still holds stale Babel or SWC artifacts.
Here’s what usually works for us under a structured integration flow (what we call the CIM Doctrine):
1. Full Environment Reset
Before changing configuration, completely clear everything that might be cached or out-of-sync:
rm -rf node_modules .next dist .cache
rm package-lock.json yarn.lock
npm install
Then re-run a clean build. If that fails again, move to the configuration layer.
2. Verify ECMAScript / Babel Support
If the AI introduced modern JS features like optional chaining (?.
), nullish coalescing (??
), or dynamic imports, you need your transpiler to recognize them.
Check your .babelrc
or babel.config.js
file:
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
useBuiltIns: 'usage',
corejs: 3,
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-syntax-dynamic-import',
],
};
This ensures any code Gemini generates with new syntax can still be parsed in older runtimes or CI environments.
3. For TypeScript Projects
Sometimes the tsconfig.json
still targets an older output mode (ES5 or ES2016) that can’t interpret the AI’s syntax.
Open tsconfig.json
and check the compiler options:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"jsx": "react-jsx",
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
A mismatch here (for example, target: "ES5"
) can trigger the same parsing failure that looks like a cache bug. It’s not.
4. Clean Scaffolding Before AI Integration
Always verify that your manual scaffold (Next.js, React, or Flutter) builds correctly before allowing AI generation.
If the base template runs fine, then you can add Gemini code in modules, not directly to the main app. This is procedural coding and helps you to stay in bounds.
That’s how you isolate where the parsing failure starts — a key part of the CIM workflow.
5. Diagnosing the Parser
If you still get Parsing error: Unexpected token
, look closely at the token and line number.
It will usually reveal which feature isn’t supported.
For example, if it flags ?.
, it means optional chaining isn’t supported by your parser configuration.
If it flags import()
, dynamic imports need the syntax plugin or an updated bundler config.
6. Fallback Strategy
If Firebase Studio’s server-side builder continues to cache (and it sometimes will) broken state, export your project locally and rebuild it using your own environment.
You can then re-import or sync it once it passes local compilation. I also recommend trying to surface Errors one more time prior to moving on.
This method ensures you rebuild from verified ground, rather than chasing errors inside the opaque build environment.
Let’s see if those steps reset the parsing loop — if not, we can go one layer deeper into the build server’s ECMAScript configuration.