Next JS 14.0.1 - Cannot get final name for export 'encodeXML' of ./node_modules/entities/lib/esm/index.js

qlfbtfca  于 2023-11-18  发布在  其他
关注(0)|答案(2)|浏览(87)

因此,我试图将我的投资组合网站部署到Vercel或Netlify,我面临着这个问题。

[23:18:24.904] Running build in Washington, D.C., USA (East) – iad1 (Hive)
[23:18:25.024] Retrieving list of deployment files...
[23:18:25.448] Previous build cache not available
[23:18:25.726] Downloading 51 deployment files...
[23:18:26.417] Running "vercel build"
[23:18:26.942] Vercel CLI 32.5.2
[23:18:27.337] Installing dependencies...
[23:18:39.394] 
[23:18:39.395] added 419 packages in 12s
[23:18:39.395] 
[23:18:39.396] 140 packages are looking for funding
[23:18:39.396]   run `npm fund` for details
[23:18:39.418] Detected Next.js version: 14.0.1
[23:18:39.422] Detected `package-lock.json` generated by npm 7+
[23:18:39.422] Running "npm run build"
[23:18:42.418] 
[23:18:42.419] > [email protected] build
[23:18:42.419] > next build
[23:18:42.419] 
[23:18:43.265] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[23:18:43.265] This information is used to shape Next.js' roadmap and prioritize features.
[23:18:43.265] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[23:18:43.266] https://nextjs.org/telemetry
[23:18:43.266] 
[23:18:43.489]    ▲ Next.js 14.0.1
[23:18:43.490]    - Environments: .env
[23:18:43.491] 
[23:18:43.492]    Creating an optimized production build ...
[23:18:53.589] Failed to compile.
[23:18:53.590] 
[23:18:53.590] ./node_modules/html-to-text/lib/html-to-text.mjs + 24 modules
[23:18:53.590] Cannot get final name for export 'encodeXML' of ./node_modules/entities/lib/esm/index.js
[23:18:53.590] 
[23:18:53.591] 
[23:18:53.592] > Build failed because of webpack errors
[23:18:53.636] Error: Command "npm run build" exited with 1
[23:18:53.840]

字符串
当我尝试手动构建时,

Failed to compile.
./node_modules/html-to-text/lib/html-to-text.mjs + 24 modules
  Cannot get final name for export 'encodeXML' of ./node_modules/entities/lib/esm/index.js
Build failed because of webpack errors
Error: Command "npm run build" exited with 1


我分享我的Package.json文件,以便更好地了解

{
  "name": "kaustubhdev",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@react-email/components": "^0.0.11",
    "@react-email/tailwind": "^0.0.12",
    "next": "14.0.1",
    "react": "^18",
    "react-dom": "^18",
    "react-hot-toast": "^2.4.1",
    "react-icons": "^4.11.0",
    "resend": "^2.0.0"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "autoprefixer": "^10.0.1",
    "eslint": "^8",
    "eslint-config-next": "14.0.1",
    "postcss": "^8",
    "tailwindcss": "^3.3.0",
    "typescript": "^5"
  }
}


即使尝试使用GitHub或直接通过CLI部署网站,此问题仍然存在

snvhrwxg

snvhrwxg1#

这是一个与重新发送电子邮件SDK版本2相关的错误,因此处理此问题的最佳方法是降级到版本1。
人们已经在GitHub上提高了PR

bkhjykvo

bkhjykvo2#

Here是另一个答案中提到的错误的链接。
以下内容修复了该问题
使用前:

const html = MagicLinkEmail({ url, host });

await resend.emails.send({
  from: env.RESEND_EMAIL_FROM,
  to: params.identifier,
  subject: `Log in to ${host}`,
  html: html,
});

字符串
之后:

import { renderAsync } from '@react-email/render'

const html = await renderAsync(MagicLinkEmail({ url, host }));

await resend.emails.send({
  from: env.RESEND_EMAIL_FROM,
  to: params.identifier,
  subject: `Log in to ${host}`,
  html: html,
});

相关问题