Hi guys, I’ve found a workaround (well, Mr Claude has).
tl;dr the @mjackson/ package has been renamespaced to @remix-run/ but the react-router/node package still has a dependency on the old version. For whatever reason, Netlify (but not Vercel??) is struggling with this.
Here are instructions from Mr Claude. Sorry for the rush but I’ve been at this all morning and I was supposed to be gone half an hour ago!
# Fix for @mjackson/node-fetch-server Deployment Issue
## Problem
When deploying to Netlify, you may encounter this error:
```
Error: Cannot find module ‘@mjackson/node-fetch-server’
```
This happens because `@react-router/node@7.8.0` has a dependency on `@mjackson/node-fetch-server` which has been replaced by `@remix-run/node-fetch-server`. The package was transferred but `@react-router/node` hasn’t been updated yet.
## Solution Overview
We patch `@react-router/node` to use `@remix-run/node-fetch-server` instead of the deprecated `@mjackson/node-fetch-server`.
## Step-by-Step Fix
### 1. Create the postinstall script
Create a file at `scripts/postinstall.js` with the patching logic that will:
- Replace all references to `@mjackson/node-fetch-server` with `@remix-run/node-fetch-server` in the `@react-router/node` package
- Create a backup copy of the package as a fallback
### 2. Add pnpm override
Add this to your `package.json` under the `pnpm` section:
```json
{
“pnpm”: {
*"overrides"*: {
*"@mjackson/node-fetch-server"*: *"npm:@remix-run/node-fetch-server@^0.8.0"*
}
}
}
```
### 3. Add postinstall script to package.json
Add to your `scripts` section in `package.json`:
```json
{
“scripts”: {
*"postinstall"*: *"node scripts/postinstall.js"*
}
}
```
### 4. Ensure @remix-run/node-fetch-server is installed
Add to your dependencies in `package.json`:
```json
{
“dependencies”: {
*"@remix-run/node-fetch-server"*: *"^0.8.0"*
}
}
```
### 5. Reinstall dependencies
```bash
rm -rf node_modules pnpm-lock.yaml
pnpm install
```
### 6. Verify the fix
Check that the patch was applied:
```bash
grep “@remix-run/node-fetch-server” node_modules/@react-router/node/dist/index.js
```
You should see output like:
```
var import_node_fetch_server = require(“@remix-run/node-fetch-server”);
```
### 7. Commit the changes
```bash
git add scripts/postinstall.js package.json pnpm-lock.yaml
git commit -m “Fix @mjackson/node-fetch-server deployment issue”
git push
```
### 8. Deploy
Your deployment should now work without the missing module error.
## How It Works
1. **pnpm override**: Tells pnpm to install `@remix-run/node-fetch-server` whenever any package requests `@mjackson/node-fetch-server`
2. **postinstall script**: After installation, patches the actual `@react-router/node` files to replace the import statements
3. **Backup copy**: Creates a copy of `@remix-run/node-fetch-server` at the `@mjackson` location as a fallback
## Temporary Solution
This is a temporary workaround until `@react-router/node` is updated to use `@remix-run/node-fetch-server` directly. Once that happens, you can remove:
- The `scripts/postinstall.js` file
- The `postinstall` script from package.json
- The pnpm override from package.json
## Troubleshooting
If you still see the error after applying this fix:
1. **Clear your deployment cache**: Most deployment platforms cache node_modules. Clear the cache and redeploy.
2. **Check the postinstall ran**: Look for these lines in your deployment logs:
```
Patching @react-router/node files…
Patched: /path/to/node_modules/@react-router/node/dist/index.js
```
3. **Verify locally**: Run `npm run build` locally and check if it completes without errors.
4. **Check Node version**: Ensure your deployment uses the same Node version as your local environment.