网站搜索

reactjs - 在构建 Next.js 应用时,Vercel 找不到模块或类型声明

我正在尝试将 Next.js 应用部署到 Vercel,而 react-swipeable 似乎有自己的类型声明,但:

Running "npm run build" ... > next build ... Failed to compile. ./components/SwipeBox.tsx:5:30 Type error: Cannot find module 'react-swipeable' or its corresponding type declarations. 3 | 4 | import { NextPage } from "next"; > 5 | import { useSwipeable } from "react-swipeable"; | ^ 6 | 7 | interface SwipeBoxProps { 8 | children: React.Rea

阅读更多 →

reactjs - 提前超时 Vercel 部署的 API 请求

我知道 Vercel 对无服务器函数有执行超时限制。有没有办法让我手动设置超时,这样就不会超过这个时间?

例如,我在一个爱好账户上,有一个5秒的超时限制。在我的自定义API路由中,我正在寻找一种方法,在5秒计时器之前“停止”此请求,并直接向我的客户端返回一个错误响应。即 res.status(500).json({error:"some error message"});

阅读更多 →

typescript - 当部署到 Vercel 时,Next-auth 的 getSession 返回 null,但我本地运行时正常

当我在本地运行这段代码时,它可以正常工作,但当我将它部署到 Vercel 时,出现 session.user.email 未定义的问题。我正在使用 GraphQL、Nexus 和 Prisma

t.field('createProject', { type: 'Project', args: { name: nonNull(stringArg()), description: nonNull(stringArg()), website: stringArg(), sourceCode: stringArg(), // userId: stringArg(), }, async resolve(_, args, ctx) { // console.log(user) try { const req = ctx.req const session = awai

阅读更多 →

typescript - Next.js - Vercel 部署错误:错误:EEXIST:文件已存在

在 Vercel 预览部署中使用 Next.js 13.0.0 时出现以下错误。

我的理解是预览部署会在任何分支更新时运行。

看起来 api 动态路由无法正常工作,因为错误发生在 address/[zipcode].ts 上。

我不知道如何修复这个错误。任何重新部署也没有效果。

重新部署

阅读更多 →

node.js - 无法在 Vercel API 文件夹中使用绝对路径

测试仓库在 https://github.com/user72356/vite-project

我正在尝试从我的应用程序的 api 目录中使用模块的绝对路径进行导入。我能够在前端部分的代码中使用绝对路径,例如 import hello from "shared/hello";,但在 api 目录中无法使用。

这样做会导致一个 Cannot find module 错误。请参阅 https://github.com/user72356/vite-project/blob/main/api/index.ts 查看实际代码。

我对 Vercel 和 Node.js 的经验有限,但我认为我可能理解其中的情况。由于 api 目录中的任何内容都在 Node 上运行,我猜测 shared/hello 并不映射到文件系统上的任何东西。它只会正确映射到网络上的某个东西,例如 example.com/shared/hello。如果我理解得对,请告诉我。

我如何才能让

阅读更多 →

reactjs - Vercel 部署无法检测接口上的属性

我正在 Vercel 上设置我的 monorepo,以部署包含在 monorepo 中的 Next.js 项目(仓库中的其他项目是 Express.js 微服务)。Next.js 项目导入了几个由 Express.js 项目生成的类型——在我的本地电脑上进行生产构建时没有类型错误,但在部署到 Vercel 时,我收到编译错误,例如:“类型错误:属性 'id' 在类型 'WorkerFullInformation' 上不存在”。

我的文件夹系统看起来是这样的:

monorepo: | /nextjs-app | /src | /pages | /dashboard | installers.tsx | /microservice-1 | /src | /types | /workers | WorkerFullInformation.ts ...

看起来 Vercel 能够导入这个,因为编译错误抱怨此类型上不存在某些属性:

阅读更多 →

typescript - Vercel 因“@”而无法部署?

我已经寻找了一段时间,也许是因为我做研究的方式,但无论如何我还是要问这个问题。

我正在处理一个 react.js/next 环境,然后我在一个我必须自定义的库上工作,该库是用 Typescript 编写的。处理这个没有问题,但当我将最终版本部署到 Vercel 时,我遇到了 3 个错误。

./helper/react-gutenberg/dist/blocks/common/audio.js 13:06:35.878 Module not found: Can't resolve '@mantine/core' in '/vercel/path0/helper/react-gutenberg/dist/blocks/common' 13:06:35.879 13:06:35.879 Import trace for requested module: 13:06:35.880 ./helper/react-gutenberg/dist/blocks/common/audio.js

阅读更多 →

reactjs - 仅在进行 POST 请求时 NestJS 和 Vercel 的 CORS 问题

GET 请求工作正常,但我正在使用 SWR 来执行 POST 请求,以将内容提交到 Firebase 并像这样修改状态中的内容,但我无法执行 POST 请求

const item = await fetcher.POST(`/jobs?user_id=${user.id}`, _job) mutate(item)

fetcher 是这样设置的,HOST 是 API 的路径

fetcher.POST = ( url, data, headers = { 'Acces

阅读更多 →

typescript - 通过 Vercel 修改 package.json?

我正在尝试使用 Vercel 部署我的作品集,但在部署时出现错误:

src/components/header/ChangeLanguage.vue(12,25): error TS7016: Could not find a declaration file for module 'vue-i18n'. '/vercel/path0/node_modules/vue-i18n/dist/vue-i18n.esm-bundler.js' implicitly has an 'any' type. There are types at '/vercel/path0/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typin

阅读更多 →

部署 - 需要关于将基于 TypeScript 的 Node 服务器部署到 Vercel 的帮助

我在运行端点的服务器上不断收到 Code: NOT_FOUND 错误。

这主要是一个基于 TypeScript 的 Node 服务器的配置设置问题。我已经很久在为这个问题而苦苦挣扎了。

而且部署摘要总是一直运行:👇

这是我的服务器目录文件结构:

Server ├─ .env ├─ dist │ ├─ index.js │ └─ model │ └─ topic.js ├─ index.ts ├─

阅读更多 →