当我尝试将 Nextjs 项目部署到 vercel 时,出现此类错误。部署一切都很好,但是一旦我偶然点击“即时回滚”,所有部署都失败,现在显示这样的错误:
[01:18:05.538] Running build in Washington, D.C., USA (East) – iad1 [01:18:05.684] Cloning github.com/BTC415/Nextjs-Supabase-Blog (Branch: main, Commit: 40caf96) [01:18:06.025] Cloning completed: 340.953ms [01:18:06.058] Previous build cache not available [01:18:06.363] Running "vercel build" [01:18:07.076] Vercel CLI 36.0.0 [01:18:07.473] Running "install" command: `npm install --legacy-peer-deps`... [01:18:11.719] npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported [01:18:13.071] npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. [01:18:13.364] npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported [01:18:15.525] npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead [01:18:15.555] npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead [01:18:31.903] [01:18:31.904] added 826 packages, and audited 827 packages in 24s [01:18:31.904] [01:18:31.905] 273 packages are looking for funding [01:18:31.905] run `npm fund` for details [01:18:31.947] [01:18:31.947] 5 vulnerabilities (1 high, 4 critical) [01:18:31.948] [01:18:31.948] To address all issues (including breaking changes), run: [01:18:31.948] npm audit fix --force [01:18:31.948] [01:18:31.948] Run `npm audit` for details. [01:18:31.981] Detected Next.js version: 14.0.2 [01:18:31.988] Detected `package-lock.json` generated by npm 7+ [01:18:31.989] Running "npm run build" [01:18:32.124] [01:18:32.124] > [email protected] build [01:18:32.124] > next build [01:18:32.124] [01:18:32.720] Attention: Next.js now collects completely anonymous telemetry regarding usage. [01:18:32.720] This information is used to shape Next.js' roadmap and prioritize features. [01:18:32.721] 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: [01:18:32.721] https://nextjs.org/telemetry [01:18:32.721] [01:18:32.817] ▲ Next.js 14.0.2 [01:18:32.818] [01:18:32.818] Creating an optimized production build ... [01:19:00.865] Failed to compile. [01:19:00.866] [01:19:00.866] ./icons/loading-dots.module.css [01:19:00.866] Error: Cannot find module '@tailwindcss/typography' [01:19:00.866] Require stack: [01:19:00.866] - /vercel/path0/tailwind.config.js [01:19:00.867] at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) [01:19:00.867] at /vercel/path0/node_modules/next/dist/server/require-hook.js:54:36 [01:19:00.867] at Function.resolve (node:internal/modules/helpers:190:19) [01:19:00.867] at _resolve (/vercel/path0/node_modules/jiti/dist/jiti.js:1:241814) [01:19:00.867] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:244531) [01:19:00.867] at /vercel/path0/tailwind.config.js:82:5 [01:19:00.867] at evalModule (/vercel/path0/node_modules/jiti/dist/jiti.js:1:247313) [01:19:00.867] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:245241) [01:19:00.867] at /vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:37:30 [01:19:00.867] at loadConfig (/vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:39:6) [01:19:00.868] [01:19:00.870] Import trace for requested module: [01:19:00.870] ./icons/loading-dots.module.css [01:19:00.870] ./icons/loading-dots.tsx [01:19:00.871] ./icons/index.ts [01:19:00.871] ./components/shared/shared-not-found.tsx [01:19:00.871] ./components/shared/index.ts [01:19:00.871] ./app/not-found.tsx [01:19:00.871] [01:19:00.871] ./icons/loading-dots.module.css [01:19:00.871] Error: Cannot find module '@tailwindcss/typography' [01:19:00.871] Require stack: [01:19:00.871] - /vercel/path0/tailwind.config.js [01:19:00.871] at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) [01:19:00.871] at /vercel/path0/node_modules/next/dist/server/require-hook.js:54:36 [01:19:00.871] at Function.resolve (node:internal/modules/helpers:190:19) [01:19:00.872] at _resolve (/vercel/path0/node_modules/jiti/dist/jiti.js:1:241814) [01:19:00.872] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:244531) [01:19:00.872] at /vercel/path0/tailwind.config.js:82:5 [01:19:00.872] at evalModule (/vercel/path0/node_modules/jiti/dist/jiti.js:1:247313) [01:19:00.872] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:245241) [01:19:00.872] at /vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:37:30 [01:19:00.872] at loadConfig (/vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:39:6) [01:19:00.872] [01:19:00.872] Import trace for requested module: [01:19:00.872] ./icons/loading-dots.module.css [01:19:00.872] ./icons/loading-dots.tsx [01:19:00.872] ./icons/index.ts [01:19:00.873] ./components/shared/shared-not-found.tsx [01:19:00.873] ./components/shared/index.ts [01:19:00.873] ./app/(main)/category/[...slug]/error.tsx [01:19:00.873] [01:19:00.873] ./icons/loading-dots.module.css [01:19:00.873] Error: Cannot find module '@tailwindcss/typography' [01:19:00.873] Require stack: [01:19:00.873] - /vercel/path0/tailwind.config.js [01:19:00.873] at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) [01:19:00.874] at /vercel/path0/node_modules/next/dist/server/require-hook.js:54:36 [01:19:00.874] at Function.resolve (node:internal/modules/helpers:190:19) [01:19:00.874] at _resolve (/vercel/path0/node_modules/jiti/dist/jiti.js:1:241814) [01:19:00.874] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:244531) [01:19:00.874] at /vercel/path0/tailwind.config.js:82:5 [01:19:00.874] at evalModule (/vercel/path0/node_modules/jiti/dist/jiti.js:1:247313) [01:19:00.874] at jiti (/vercel/path0/node_modules/jiti/dist/jiti.js:1:245241) [01:19:00.874] at /vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:37:30 [01:19:00.874] at loadConfig (/vercel/path0/node_modules/tailwindcss/lib/lib/load-config.js:39:6) [01:19:00.874] [01:19:00.874] Import trace for requested module: [01:19:00.874] ./icons/loading-dots.module.css [01:19:00.874] ./icons/loading-dots.tsx [01:19:00.874] ./icons/index.ts [01:19:00.875] ./components/shared/shared-not-found.tsx [01:19:00.875] ./components/shared/index.ts [01:19:00.875] ./app/api/og/route.tsx [01:19:00.875] ./node_modules/next/dist/build/webpack/loaders/next-app-loader.js?name=app%2Fapi%2Fog%2Froute&page=%2Fapi%2Fog%2Froute&pagePath=private-next-app-dir%2Fapi%2Fog%2Froute.tsx&appDir=%2Fvercel%2Fpath0%2Fapp&appPaths=%2Fapi%2Fog%2Froute&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D!./app/api/og/route.tsx?__next_edge_ssr_entry__ [01:19:00.875] [01:19:00.877] [01:19:00.877] > Build failed because of webpack errors [01:19:00.940] Error: Command "npm run build" exited with 1 [01:19:01.383]
它在我的本地电脑上运行良好,但在 vercel 上不起作用。 我的意思是,我尝试在本地电脑上构建并启动,它运行良好,没有任何错误。 但在vercel上总是失败。 请帮我修复这个错误。 先谢谢你了
根据您从 Vercel 部署中提供的错误日志,我认为主要问题是找不到模块 @tailwindcss/typography。如果项目中缺少或未正确安装必要的依赖项,则可能会发生这种情况。
以下步骤可帮助您解决问题:
package.json
中已将 @tailwindcss/typography 列为依赖项。如果它不存在,您需要安装它。
在本地环境中运行以下命令:npm install @tailwindcss/typography
npm install
使用
npm install --legacy-peer-deps
可用于处理对等依赖问题,但通常仅在您面临特定依赖冲突时才需要。
module.exports = { // ... plugins: [require('@tailwindcss/typography')], }
清除缓存并重建 有时,Vercel 可能会缓存以前失败的构建。转至项目的 Vercel 仪表板清除部署缓存。
执行本地构建 在再次部署之前,最好确保您的项目在本地成功构建。运行:
npm run build
检查是否有任何可能需要解决的错误或警告。