我收到此错误,但仅在 Vercel 中,而不是本地,为什么?
error: 'FontAwesomeIcon' cannot be used as a JSX component.
Run Code Online (Sandbox Code Playgroud)
./components/Services/ServiceContainer.tsx:25:6
12:01:54.967 Type error: 'FontAwesomeIcon' cannot be used as a JSX component.
12:01:54.967 Its element type 'ReactElement<any, any> | Component<FontAwesomeIconProps, any, any>' is not a valid JSX element.
12:01:54.968 Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'Element | ElementClass'.
12:01:54.968 Type 'Component<FontAwesomeIconProps, any, any>' is not assignable to type 'ElementClass'.
12:01:54.968 The types returned by 'render()' are incompatible between these types.
12:01:54.968 Type 'React.ReactNode' is not …Run Code Online (Sandbox Code Playgroud) 当我尝试构建 Next.Js 应用程序时,成功构建后会出现以下错误。当我在 Vercel 中部署应用程序时,会显示此错误。
error - ESLint: Failed to load config "next/babel" to extend from. Referenced from: /vercel/path0/.eslintrc.json
Run Code Online (Sandbox Code Playgroud)
这是我的.eslintrc.json
{
"extends": ["next/babel","next/core-web-vitals"]
}
Run Code Online (Sandbox Code Playgroud)
我还添加了.babelrc
{
"presets": ["next/babel"],
"plugins": []
}
Run Code Online (Sandbox Code Playgroud)
当我更改eslintrc.json文件时,我还找到了一个解决方案,如下所示:
{
"extends": ["next","next/core-web-vitals"]
}
Run Code Online (Sandbox Code Playgroud)
那么构建应用程序时不会显示任何错误。但是当我使用上述解决方案时出现另一个问题,问题是:
Parsing error: Cannot find module 'next/babel'
Run Code Online (Sandbox Code Playgroud)
这在所有带有红色标记的导入中都显示出来。
我尝试搜索解决方案,但没有找到任何解决方案。
我尝试将我的应用程序部署到 Vercel(create-react-app starter)。部署成功,控制台或我的 vercel 帐户中没有错误。但是当我点击链接时,我收到以下消息:
404:NOT_FOUND 代码:NOT_FOUND ID:...
如何解决这个问题?我有 React(钩子、路由器)和 Redux 存储,没有数据库,没有 next.js。谢谢你!
我在 Next.js 中开发了一个应用程序。对于后端,我使用了 Nextjs 中配置的 api 端点,它们位于pages/api. api 端点经常返回 502(网关超时错误)或 504(我们的部署存在问题)。
经过一些研究,我发现发生这种情况是因为服务器超时。对于我部署了 Nextjs 应用程序的 Vercel,无服务器函数的最长超时时间为 10 秒。
端点之一的代码(https://bulkbays.com/api/fetchSections)是
import db from "../../config/db";
import Section from "../../Models/Section";
db();
export default async function handler(req, res) {
console.log('Entered the serverless function')
Section.find()
.lean()
.then((sections) => {
console.log('Fetched Sections',sections)
return res.json(sections);
})
.catch((err) => {
console.log('Error in fetching sessions',err)
return res.json({
status: false,
msg: "An unexpected problem occured",
err,
});
});
}Run Code Online (Sandbox Code Playgroud)
请有人告诉我怎么会超过10秒。这是人们可以进行的最简单的查询。此外,此查询的结果只是一个长度为 9 的数组,其中对象作为项目,其值包含字符串。它看起来像这样
[
{
"_id":"6092a55478ccc2092c5e41b0",
"images":["http://res.cloudinary.com/bulkbays97/image/upload/v1620223428/eysvsch2hf4ymajizzcn.jpg","http://res.cloudinary.com/bulkbays97/image/upload/v1620223429/qiwa2idfrntiygsfmnx2.jpg","http://res.cloudinary.com/bulkbays97/image/upload/v1620223429/elwhjk7abwcde7ccqcxf.jpg","http://res.cloudinary.com/bulkbays97/image/upload/v1620223428/yuzhe8iehcyj1rmfyr09.jpg"],
"title":"P-Caps", …Run Code Online (Sandbox Code Playgroud)有没有办法选择要部署的自定义分支?我似乎无法选择分支,它采用默认的主分支
提前致谢
我有一个 nextjs 应用程序部署到 Vercel,并且正在尝试将管理它的 Strapi cms 也部署到 Vercel,因为在同一服务上维护这两个应用程序会更容易。
Strapi 存储库构建良好,所有内容都是绿色的,但如果所有设置均为默认设置,我会看到 404,如果我将构建文件夹设置为“build”,则会看到空白页。
我确信这应该是一个简单的修复,但我无法弄清楚,有人这样做过吗?
我在 Vercel 上部署了一个 Nuxt.js 服务器端网站。我注意到,在某些情况下,我会收到504: GATEWAY_TIMEOUT错误,并显示代码FUNCTION_INVOCATION_TIMEOUT和消息“此无服务器函数已超时”。
为什么我会看到这个错误?
我正在使用 Nodemailer 在我的无服务器 Next.js 项目中发送电子邮件,该项目部署在 Vercel 中,该项目在开发模式下完美运行。但我在生产中遇到了问题。没有返回错误,一切都与开发模式相同,只是我没有收到任何电子邮件。
我有另一个用 React 构建的项目,并部署在 Heroku 中,我以相同的方式发送电子邮件,并且它在开发和生产方面工作正常,所以我知道问题出在 Vercel 上。
是的,我在 Google 帐户中启用了“允许安全程度较低的应用程序”,并且是的,我启用了验证码。
我也读过这篇文章https://vercel.com/docs/solutions/email但它并没有真正让我明白在我的情况下我应该做什么。我可以看到这是 SMTP 的问题,但我不知道到底是什么。
有人遇到过这种问题吗?我怎样才能解决这个问题?
const transporter = nodemailer.createTransport({
host: "smtp.gmail.com",
port: 465,
auth: {
user: myEmail@gmail.com,
pass: myEmailPass
}
});
const mailOptions = {
from: `${req.body.name} ${req.body.email}`,
to: myEmail@gmail.com,
subject: `${req.body.subject}`,
text: `Text: ${req.body.text}`
}
transporter.sendMail(mailOptions, (err, res) => {
if(err) {
console.log(err);
} else {
console.log("success");
}
});
Run Code Online (Sandbox Code Playgroud)
更新
我更改为 SendGrid:创建了一个帐户,创建了一个 API 密钥,并像这样更改了代码(而不是上面的代码):
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: `myEmail@gmail.com`, …Run Code Online (Sandbox Code Playgroud) 我已经尝试将 nuxt 应用程序部署到 Vercel 几天了,但收到此错误消息:Error: error:0308010C:digital envelope routines::unsupported
我在本地计算机上解决了这个问题,将我的 node.js 降级到 16+,但在生产环境中仍然出现这种情况。我尝试将其设置--openssl-legacy-provider为 package.json 中的脚本对象,但没有效果。附:我不太确定语法是否正确,因为大多数答案都是针对反应的。
这是整个错误:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
at module.exports (/vercel/path0/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/vercel/path0/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/vercel/path0/node_modules/webpack/lib/NormalModule.js:471:10)
at /vercel/path0/node_modules/webpack/lib/NormalModule.js:503:5
at /vercel/path0/node_modules/webpack/lib/NormalModule.js:358:12
at /vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at Array.<anonymous> (/vercel/path0/node_modules/webpack/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/vercel/path0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:55:16)
at /vercel/path0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:91:9
at /vercel/path0/node_modules/graceful-fs/graceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js …Run Code Online (Sandbox Code Playgroud) 在 Vercel 上部署后是否有部署后挂钩或任何其他方式来运行 Node 脚本?
vercel ×10
next.js ×5
deployment ×2
node.js ×2
nuxt.js ×2
reactjs ×2
serverless ×2
babeljs ×1
eslint ×1
eslintrc ×1
javascript ×1
lambda ×1
nodemailer ×1
sendgrid ×1
server ×1
strapi ×1