Hey!
I am following the guide found at: How to deploy a React Router 7 site to Netlify | Netlify Developers
Everything seems fine, until I am hitting this error:
12:50:11 PM: (build.command completed in 10.3s)
12:50:11 PM:
12:50:11 PM: Functions bundling
12:50:11 PM: ─────────────
12:50:11 PM:
12:50:11 PM: Packaging Functions generated by your framework:
12:50:11 PM: - react-router-server.mjs
12:50:11 PM:
12:50:11 PM: ✘ [ERROR] Could not resolve "../../../build/server/server.js"
12:50:11 PM: .netlify/v1/functions/react-router-server.mjs:2:28:
12:50:11 PM: 2 │ export { default } from "../../../build/server/server.js";
The directory ./build/server is created, but with index.js inside, not with server.js.
I never used any cloud functions on Netlify, so I don’t know how to debug it.
Sitename: buszewskiv2.netlify.app (never deployed due to the issue).
I can’t paste the full log due to posting limitations.
Just wanted to say that I made it working by changing netlify.toml’s build command to command = "react-router build && cp build/server/index.js build/server/server.js"
. Feels like an extreme hack though.
Do you have a minimal reproduction available to share?
Nope, sorry, that’s private repo for now. But it’s react-router 7.1.1 with a pretty standard config, so I don’t think you’ll have different results with a clean rr7 install.
Feel free to share a repo with a clearn RR7 install and I’ll be happy to check that.
someone created this issue that should help you if you want to reproduce the error :
opened 07:32AM - 24 Jun 25 UTC
Steps I took to create the error:
- Install the [Netlify Template](https://gith… ub.com/remix-run/react-router-templates/tree/main/netlify) within this repo using `npx create-react-router@latest --template remix-run/react-router-templates/netlify`
- Follow the screenshot below
<img width="706" alt="Image" src="https://github.com/user-attachments/assets/d8772a37-8339-4271-918d-16ecb3c94cff" />
- Install dependencies using `yarn install`
- Run the app: `yarn dev`, which starts up fine
- Create a production build using `yarn build`
- Start production build using `yarn start`. Production asset was completely generated, but failed to start with the following error
```bash
✓ 3 assets cleaned from React Router server build.
build/client/assets/logo-dark-pX2395Y0.svg
build/client/assets/logo-light-CVbx2LBR.svg
build/server/assets/server-build-DvXAPJGF.css
✓ built in 64ms
(build.command completed in 1.8s)
Functions bundling
────────────────────────────────────────────────────────────────
Packaging Functions from .netlify/functions-internal directory:
- handler/index.js
(Functions bundling completed in 436ms)
Netlify Build Complete
────────────────────────────────────────────────────────────────
(Netlify Build completed in 2.3s)
◈ Static server listening to 3999
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
Request from ::1: GET /
◈ Function handler has returned an error: Cannot find module '/Users/xxx/Documents/test-deploy/.netlify/functions-serve/.unzipped/handler/node_modules/@react-router/node/dist/index.mjs' imported from /Users/xxx/Documents/test-deploy/.netlify/functions-serve/.unzipped/handler/.netlify/functions-internal/handler/index.mjs
```
I created a fresh repo without using the `--template` with `npx create-react-router@latest`, and I am getting the same error when starting the production locally after installing `@netlify/vite-plugin-react-router` following the [link](https://developers.netlify.com/guides/how-to-deploy-a-react-router-7-site-to-netlify/) from Netlify. I deploy the project to Netlify and I am getting an Internal Error. See [here](https://analytics-logging.netlify.app/).