无法在 netlify 上使用 tRPC 构建我的前端应用程序

imp*_*tle 6 typescript reactjs trpc.io

我正在使用 React Typescript,并且按照tRPC 文档进行服务器/客户端设置,但出现此错误。有谁知道为什么部署时会发生这种情况?我在本地使用的时候效果还好吗?

\n
8:41:46 AM: TS2339: Property \'createClient\' does not exist on type \'"useContext collides with a built-in method, you should rename this router or procedure on your backend" | "Provider collides with a built-in method, you should rename this router or procedure on your backend" | "createClient collides with a built-in method, you should rename this router or procedure on your backend...\'.\n8:41:46 AM:   Property \'createClient\' does not exist on type \'"useContext collides with a built-in method, you should rename this router or procedure on your backend"\'.\n8:41:46 AM:     42 |   const [queryClient] = useState(() => new QueryClient());\n8:41:46 AM:     43 |   const [trpcClient] = useState(() =>\n8:41:46 AM:   > 44 |     trpc.createClient({\n8:41:46 AM:        |          ^^^^^^^^^^^^\n8:41:46 AM:     45 |       links: [\n8:41:46 AM:     46 |         httpBatchLink({\n8:41:46 AM:     47 |           url: `${process.env.REACT_APP_BACKEND_URL}/trpc`,\n8:41:46 AM: \xe2\x80\x8b\n8:41:46 AM:   "build.command" failed        \n
Run Code Online (Sandbox Code Playgroud)\n

我的应用程序.tsx

\n
export default function App() {\n  const [queryClient] = useState(() => new QueryClient());\n  const [trpcClient] = useState(() =>\n    trpc.createClient({\n      links: [\n        httpBatchLink({\n          url: `${process.env.REACT_APP_BACKEND_URL}/trpc`,\n        }),\n      ],\n    })\n  );\n\n  return (\n    <trpc.Provider client={trpcClient} queryClient={queryClient}>\n      <QueryClientProvider client={queryClient}>    \n........... rest of code here\n\n\n\n        \n
Run Code Online (Sandbox Code Playgroud)\n

Kus*_*nal 2

这是因为您是trpc从后端导入的,这是因为您在本地编译了后端,但在 Netlify/Vercel 上部署时跳过了该步骤。