Reference

Build errors and how to fix them

These are the failures React2Static recognises on its own when a build breaks. Every entry below shows the real output npm, Vite or tsc prints, so you can search for the line you actually got — or drop your project into the builder and it will tell you which one you hit.

The package names, paths and sizes in the examples below are only examples — the builder fills in the ones from your own project.

Cannot resolve react-router-dom

What you see

error during build:
[vite]: Rollup failed to resolve import "react-router-dom" from "/home/project/src/App.tsx".
This is most likely unintended because it can break your application at runtime.

The code imports react-router-dom, but it is not listed in package.json, so it was never installed. Add it to dependencies, or remove the import. This is the most common failure in AI-generated projects — it works on the machine that wrote it because the package is already there.

The fix

npm install react-router-dom

package.json has no build script

What you see

npm error Missing script: "build"
npm error
npm error To see a list of scripts, run:
npm error   npm run

We run npm run build, and there is nothing to run. Add a build script — for a Vite project that is "build": "vite build".

The fix

{
  "scripts": {
    "build": "vite build"
  }
}

TypeScript rejected the code

What you see

src/components/PostCard.tsx:12:23 - error TS2339: Property 'title' does not exist on type 'Post'.

12   <h2>{post.title}</h2>
                 ~~~~~

The build script runs tsc before bundling and type checking failed. Fix the file named in the log, or change the build script to run the bundler only — "vite build" instead of "tsc && vite build".

The fix

{
  "scripts": {
    "build": "vite build"
  }
}

vite is not installed

What you see

> my-app@0.0.0 build
> vite build

sh: 1: vite: not found

The build script calls vite, but it is not in package.json, so it never got installed. Add it to devDependencies.

The fix

npm install -D vite

Dependency versions conflict

What you see

npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: my-app@0.0.0
npm error Found: react@19.0.0

Two packages want incompatible versions of the same dependency. We already retried the install with --legacy-peer-deps and it still failed, so the versions in package.json have to be reconciled by hand.

The package @shadcn/ui-toast does not exist

What you see

npm error code E404
npm error 404 Not Found - GET https://registry.npmjs.org/@shadcn%2fui-toast
npm error 404 '@shadcn/ui-toast@^1.0.0' is not in this registry.

npm cannot find it in the registry. AI tools sometimes invent package names, and private packages are not reachable from here. Check the spelling in package.json, or drop the dependency if nothing imports it.

No published version matches react@^19.9.0

What you see

npm error code ETARGET
npm error notarget No matching version found for react@^19.9.0.

The package exists but that version range does not. Loosen the range in package.json, or pin it to a version that was actually published.

The build produced no output folder

What you see

vite v5.4.10 building for production...
✓ 41 modules transformed.
✓ built in 1.24s

The build itself finished without errors, but there is nothing to collect. We look in dist/, build/ and out/ — check which directory your build config writes to.

Next.js did not produce static files

What you see

▲ Next.js 14.2.5

✓ Compiled successfully
✓ Generating static pages (5/5)

Route (app)                    Size     First Load JS

By default next build writes a server application to .next/. Add output: "export" to next.config.js and build again — that writes plain files to out/, which we can pick up. Server-side features (API routes, server actions, image optimisation) do not survive the export.

The fix

// next.config.js
module.exports = {
  output: 'export',
}

The build ran out of memory

What you see

<--- Last few GCs --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

A build inside the browser gets a limited amount of memory, and this project went past it. Removing unused dependencies and oversized assets usually brings it back under; otherwise this one has to be built on your own machine.

This looks like part of a monorepo

What you see

npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*

package.json uses workspace: dependencies, which only resolve inside the full repository. Upload just the app itself, with real version numbers in place of the workspace: references.

The project asks for a different Node version

What you see

npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE   package: 'some-package@3.0.0',
npm warn EBADENGINE   required: { node: '>=22.0.0' },
npm warn EBADENGINE   current: { node: 'v20.11.1' }
npm warn EBADENGINE }

A dependency declares a Node version this environment does not provide. Relax the engines field, or move to a release of that package which supports current Node.

The npm registry could not be reached

What you see

npm error code EAI_AGAIN
npm error network request to https://registry.npmjs.org/react failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org

The download broke off partway. This is usually temporary — just retry the build. Where registry.npmjs.org is blocked you will need a VPN.

Let it find yours

Drop your ZIP into the builder. It runs the real build in your browser, and when something breaks it points at the line that matters instead of handing you the whole log.

Open the builder

See also

What to check before you put a static site onlineThe 15 things React2Static checks in your build output before you deploy — exposed keys, dead API calls, missing meta tags — and how to fix each one.