错误:Hobby 计划的部署中最多可以添加 12 个无服务器功能。下一个js

问题描述 投票:0回答:2

什么才算是无服务器功能?

我有一个网站,https://contribute.meyabase.com/,它已经在 Next Js 上存在了一段时间,最近在尝试部署时,我收到了错误

Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more.

我不使用

getStaticPaths
/
getServerSideProps
getIntitialProps
。我只用
SWR
。我唯一拥有的功能是
auth0.com
API 路由(其中 6 个)。

以下是构建日志

[21:26:55.979] Cloning github.com/axelmukwena/meyabase-contribute-client (Branch: main, Commit: 7cd2594)
[21:26:56.636] Cloning completed: 656.77ms
[21:26:59.495] Restored build cache
[21:26:59.537] Running "vercel build"
[21:27:00.000] Vercel CLI 28.13.0
[21:27:00.255] Warning: When using Next.js, it is recommended to place Node.js Serverless Functions inside of the `pages/api` (provided by Next.js) directory instead of `api` (provided by Vercel). Learn More: https://nextjs.org/docs/api-routes/introduction
[21:27:00.771] Installing dependencies...
[21:27:01.921] 
[21:27:01.921] up to date in 877ms
[21:27:01.921] 
[21:27:01.921] 102 packages are looking for funding
[21:27:01.921]   run `npm fund` for details
[21:27:01.933] Detected Next.js version: 13.0.3
[21:27:01.938] Detected `package-lock.json` generated by npm 7+...
[21:27:01.939] Running "npm run build"
[21:27:02.247] 
[21:27:02.247] > [email protected] build
[21:27:02.248] > next build
[21:27:02.248] 
[21:27:02.782] info  - Linting and checking validity of types...
[21:27:33.133] info  - Creating an optimized production build...
[21:28:27.861] info  - Compiled successfully
[21:28:27.861] info  - Collecting page data...
[21:28:34.338] info  - Generating static pages (0/35)
[21:28:34.607] info  - Generating static pages (8/35)
[21:28:34.847] info  - Generating static pages (17/35)
[21:28:35.011] info  - Generating static pages (26/35)
[21:28:35.200] info  - Generating static pages (35/35)
[21:28:35.250] info  - Finalizing page optimization...
[21:28:35.261] 
[21:28:35.280] Route (pages)                              Size     First Load JS
[21:28:35.280] ┌ ○ /                                      5.03 kB         379 kB
[21:28:35.280] ├   /_app                                  0 B             221 kB
[21:28:35.280] ├ ○ /[username]                            4.1 kB          396 kB
[21:28:35.280] ├ ○ /404                                   841 B           258 kB
[21:28:35.281] ├ ○ /500                                   775 B           258 kB
[21:28:35.281] ├ ○ /about                                 5.13 kB         335 kB
[21:28:35.281] ├ ○ /account                               1.91 kB         289 kB
[21:28:35.281] ├ ○ /admin                                 5.12 kB         373 kB
[21:28:35.281] ├ ○ /admin/articles                        5.31 kB         413 kB
[21:28:35.281] ├ ○ /admin/audio                           644 B           258 kB
[21:28:35.281] ├ ○ /admin/paragraphs                      4.37 kB         412 kB
[21:28:35.281] ├ ○ /admin/sentences                       5.11 kB         373 kB
[21:28:35.281] ├ ○ /admin/users                           6.83 kB         289 kB
[21:28:35.281] ├ λ /api/auth/[...auth0]                   0 B             221 kB
[21:28:35.281] ├ λ /api/auth/callback                     0 B             221 kB
[21:28:35.282] ├ λ /api/auth/login                        0 B             221 kB
[21:28:35.282] ├ λ /api/auth/logout                       0 B             221 kB
[21:28:35.282] ├ λ /api/auth/me                           0 B             221 kB
[21:28:35.282] ├ λ /api/auth/signup                       0 B             221 kB
[21:28:35.282] ├ ○ /articles                              1.53 kB         381 kB
[21:28:35.282] ├ ○ /articles/[articleSlug]                2.03 kB         373 kB
[21:28:35.282] ├ ○ /competition                           4.42 kB         334 kB
[21:28:35.282] ├ ○ /login                                 1.19 kB         233 kB
[21:28:35.282] ├ ○ /paragraphs                            5.75 kB         379 kB
[21:28:35.282] ├ ○ /paragraphs/[paragraphSlug]            2.79 kB         382 kB
[21:28:35.283] ├ ○ /privacy-policy                        5.93 kB         336 kB
[21:28:35.283] ├ ○ /rankings                              631 B           258 kB
[21:28:35.283] ├ ○ /recordings                            5.2 kB          373 kB
[21:28:35.283] ├ ○ /recordings/[recordingSlug]            2.65 kB         370 kB
[21:28:35.283] ├ ○ /reports                               4.45 kB         377 kB
[21:28:35.283] ├ ○ /reports/[reportSlug]                  3.55 kB         373 kB
[21:28:35.283] ├ ○ /search                                13.3 kB         383 kB
[21:28:35.283] ├ ○ /sentences                             698 B           258 kB
[21:28:35.284] ├ ○ /sentences/[sentenceSlug]              3.36 kB         385 kB
[21:28:35.284] ├ ○ /signup                                1.21 kB         233 kB
[21:28:35.284] ├ ○ /suggestions                           9.57 kB         303 kB
[21:28:35.284] ├ ○ /suggestions/[suggestionSlug]          4.65 kB         285 kB
[21:28:35.284] ├ ○ /terms-of-service                      7.56 kB         337 kB
[21:28:35.284] ├ ○ /translations                          4.82 kB         381 kB
[21:28:35.284] ├ ○ /translations/[translationSlug]        2.57 kB         372 kB
[21:28:35.284] ├ ○ /words                                 6.59 kB         378 kB
[21:28:35.284] └ ○ /words/[wordSlug]                      2.59 kB         370 kB
[21:28:35.284] + First Load JS shared by all              222 kB
[21:28:35.285]   ├ chunks/framework-05c5206d76924e06.js   45.7 kB
[21:28:35.285]   ├ chunks/main-1a2cd11733cdaa06.js        31.9 kB
[21:28:35.285]   ├ chunks/pages/_app-86a6c0b57a58efc3.js  142 kB
[21:28:35.285]   ├ chunks/webpack-8b448ac738e18d4a.js     1.37 kB
[21:28:35.285]   └ css/daa1d5f9bb57d053.css               690 B
[21:28:35.285] 
[21:28:35.285] λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
[21:28:35.285] ○  (Static)  automatically rendered as static HTML (uses no initial props)
[21:28:35.285] 
[21:28:36.585] Traced Next.js server files in: 1.097s
[21:28:37.694] Created all serverless functions in: 1.106s
[21:28:37.720] Collected static files (public/, static/, .next/static): 21.326ms
[21:28:37.959] Using TypeScript 4.7.4 (local user-provided)
[21:28:42.910] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.281] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.565] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.712] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.878] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.049] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.187] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.341] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.483] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.633] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.907] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.997] Using TypeScript 4.7.4 (local user-provided)
[21:28:47.211] Build Completed in /vercel/output [2m]
[21:28:49.879] Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more.
lambda next.js serverless
2个回答
3
投票

虽然这与 Next.Js 无关,但我在开发的另一种应用程序中也有同样的经历。起初,我认为这可能是我的 Python 应用程序使用 FastAPI 的端点数量,但根据我在论坛上读到的评论“您在 vercel.json 文件中声明的每个路由都是无服务器函数”。这意味着我在 "builds":[{"src": "src/*.py"}] 中声明的内容。在我的例子中,.py 文件的数量从几个增加到超过 12 个,但实际上我的 API 集中在一个

index.py
文件中,其中声明了所有端点。解决方案是更改 "builds":[{"src": "src/index.py"}] (不带
*.py
通配符)。换句话说,每个 .py 文件都被视为一个函数。


0
投票

我在我的 nextjs 项目(应用程序路由器)的 vercel 构建中遇到此错误。

正如 vercel 文档 here 所说:

默认情况下,Nodejs 运行时构建并提供创建的任何函数 在 Vercel 项目的 /api 目录中。

就我而言,我已经在 api 文件夹中创建了大部分 React 查询 api 挂钩,这就是我收到此错误的原因。

我的文件夹结构

将文件夹名称从 api 更改为 apis 后,错误消失了。您可以将文件夹名称从 api 更改为任何其他有意义的名称。

© www.soinside.com 2019 - 2024. All rights reserved.