JAE*_*AE5 3 typescript reactjs next.js vercel
我正在尝试使用 vercel cli 部署 Next 应用程序。我已经运行vercel build并且成功完成,没有错误 - 下面提供了上下文。我已经运行了该vercel deploy --prebuilt命令,并且部署没有错误。当我尝试将项目从预览环境移动到生产环境时,出现错误
Error: No Next.js version could be detected in your project. Make sure `"next"` is installed in "dependencies" or "devDependencies"
Run Code Online (Sandbox Code Playgroud)
这是我的 package.json
{
"name": "portfolio-website",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@heroicons/react": "^2.0.12",
"@next/swc-darwin-x64": "^12.3.2",
"framer-motion": "^7.6.2",
"next": "^12.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.38.0",
"react-simple-typewriter": "^4.0.5",
"react-social-icons": "^5.15.0"
},
"devDependencies": {
"@types/node": "18.11.7",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"autoprefixer": "^10.4.12",
"eslint": "8.26.0",
"eslint-config-next": "13.0.0",
"postcss": "^8.4.18",
"tailwind-scrollbar": "^2.0.1",
"tailwindcss": "^3.2.1",
"typescript": "4.8.4"
},
"optionalDependencies": {
"@next/swc-linux-x64-gnu": "12.3.2"
}
}
Run Code Online (Sandbox Code Playgroud)
我也有错误 - 对于上下文
warn - Attempted to load @next/swc-darwin-x64, but it was not installed
error - Failed to load SWC binary for darwin/x64, see more info here: https://nextjs.org/docs/messages/failed-loading-swc
info - Creating an optimized production build .Error: Command "npm run build" exited with
Run Code Online (Sandbox Code Playgroud)
我必须删除我的 package.lock.json 填充和 node_modules 并运行npm i @next/swc-darwin-x64 ,npm i即使当时的依赖项已经在我的锁定文件中。
我也尝试过降级我的下一个版本,但没有成功。
已尝试直接从我的 git 存储库进行部署,但我也遇到了相同的错误
[22:29:17.748] Cloning github.com/xxxxx/xxxxxx (Branch: main, Commit: 0fb5a5a)
[22:29:18.540] Cloning completed: 791.508ms
[22:29:19.131] Looking up build cache...
[22:29:19.371] Build Cache not found
[22:29:19.420] Running "vercel build"
[22:29:20.057] Vercel CLI 28.4.12-05a80a4
[22:29:20.485] Installing dependencies...
[22:29:21.273] npm ERR! code EBADPLATFORM
[22:29:21.275] npm ERR! notsup Unsupported platform for @next/swc-darwin-x64@12.3.2: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
[22:29:21.276] npm ERR! notsup Valid OS: darwin
[22:29:21.276] npm ERR! notsup Valid Arch: x64
[22:29:21.276] npm ERR! notsup Actual OS: linux
[22:29:21.276] npm ERR! notsup Actual Arch: x64
[22:29:21.279]
[22:29:21.279] npm ERR! A complete log of this run can be found in:
[22:29:21.279] npm ERR! /vercel/.npm/_logs/2022-11-02T21_29_20_898Z-debug-0.log
[22:29:21.290] Warning: Could not identify Next.js version, ensure it is defined as a project dependency.
[22:29:21.364] Error: No Next.js version could be detected in your project. Make sure `"next"` is installed in "dependencies" or "devDependencies"
Run Code Online (Sandbox Code Playgroud)
我遇到了这个问题,并通过清除我在 vercel 配置中的“根目录”设置中放置的内容来解决它。
我正在对其他问题进行故障排除并将其设置为“src”,这导致它开始出现。当我将其设置为空时,部署再次正常工作
| 归档时间: |
|
| 查看次数: |
9857 次 |
| 最近记录: |