1

I upgraded my remix app to react-router-v7 but cannot get it to deploy on Vercel (used to work fine).

I have done all the things all the internet says but something is going wrong with the type imports it seems.

This is the errorlog

✓ 114 modules transformed.
x Build failed in 1.54s
Could not resolve "./+types/layout" from "app/routes/website/layout.tsx"
file: /vercel/path0/app/routes/website/layout.tsx
    at getRollupError (file:///vercel/path0/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
    at error (file:///vercel/path0/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
    at ModuleLoader.handleInvalidResolvedId (file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:20088:24)
    at file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:20048:26 {
  code: 'UNRESOLVED_IMPORT',
  exporter: './+types/layout',
  id: '/vercel/path0/app/routes/website/layout.tsx',
  watchFiles: [
    '/vercel/path0/node_modules/@react-router/dev/dist/config/defaults/entry.client.tsx',
    '/vercel/path0/app/root.tsx',
    '/vercel/path0/app/routes/website/layout.tsx',
    '/vercel/path0/app/routes/website/index.tsx',
    '/vercel/path0/app/routes/website/login.tsx',
    '/vercel/path0/app/routes/website/forgot-password.tsx',
    '/vercel/path0/app/routes/website/signup.tsx',
    '/vercel/path0/app/routes/website/signup.success.tsx',
    '/vercel/path0/app/routes/website/privacy.tsx',
    '/vercel/path0/app/routes/website/terms.tsx',
    '/vercel/path0/app/routes/website/update-password.tsx',
    '/vercel/path0/app/routes/website/logout.tsx',

It goes on much longer basically every file there is gives this error. Locally it works fine.

Anyone any idea I am quite desperate.

3 Answers 3

2

React Router v7 is now supported on Vercel: https://x.com/vercel_changes/status/1890104465862332725

Sign up to request clarification or add additional context in comments.

Comments

1

For me the issue was caused by using:

import { type Route } from "./+types/post"; ❌ wrong

instead of:

import type { Route } from "./+types/post"; ✅ good

Comments

0

Have you tried using the vercel template at https://github.com/remix-run/react-router-templates?

You can just copy the configs from https://github.com/remix-run/react-router-templates/tree/main/vercel Specifically, you'll want to update:

  • your build script to "build": "react-router build && node vercel/prepare.js",
  • copy dev-server.js and add to root.
  • copy the server dir.
  • copy the vercel dir.
  • update vite.config.ts to match
  • remove any existing start script

Hope that helps.

2 Comments

Actually, looking at the error, it seems this may just be an unresolved import and not related to vercel, eg there is type generated by react router that cannot be found. Are you able to reproduce the issue locally, eg run a local build and serving built version locally? Also, double check your tsconfig settings based on the instructions at reactrouter.com/upgrading/remix#7-enable-type-safety
you were right - it was the eslint that messed up the import. was able to solve it. sorry for confusion and thanks for assistance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.