简体   繁体   English

react18 + vite (v4) + Typescript 和 react-router-6 上的 Netlify 或 Vercel 构建错误

[英]Netlify or Vercel build error on react18 + vite (v4) + Typescript with react-router-6

While added react-router in ./src/App.tsx there was no problem on.netlify or vercel build-time.在 ./src/App.tsx 中添加 react-router 时, ./src/App.tsx或 vercel 构建时没有问题。 But, error occurs when I imported them from a custom folder like...但是,当我从自定义文件夹导入它们时发生错误,例如...

netlify-build-error netlify-构建错误

But in a local machine, it is ok while run: yarn build但是在本地机器上,运行时没问题: yarn build

local-ss本地SS

src
│___App.tsx
|___Router.tsx
│
└───pages
│   |___HomePage.tsx
|   |___Notfound.tsx
|   |___index.ts

I'm exporting all page components from ./src/pages/index.ts .我正在从./src/pages/index.ts导出所有页面组件。

Node Version: 18.x节点版本:18.x

Vite: 4.x邀请:4.x

Plugin: @vitejs/plugin-react插件:@vitejs/plugin-react

Typescript: 4.9.x Typescript:4.9.x

repository: (PR) https://github.com/0xMahabub/react-vite-ts-swc-zustand/pull/2存储库:(PR) https://github.com/0xMahabub/react-vite-ts-swc-zustand/pull/2

I have tried to figure this out but couldn't get it myself I wish to find the actual problem and its solution and get rid of this issue.我试图弄清楚这一点,但自己无法解决我希望找到实际问题及其解决方案并摆脱这个问题。 Then I can go ahead.然后我可以提前go。

It looks like, you forgot to add files in pages directory to staged files when you were commiting them... because they are not in you repo just write git add.看起来,您在提交文件时忘记将pages目录中的文件添加到staged文件中……因为它们不在您的存储库中,只需写入git add. (if you have.gitignore file!) in you root folder and then commit>push (如果你有 .gitignore 文件!)在你的根文件夹中,然后提交>推送

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM