部署服务器上的Next.js版本问题:"Next:Not Found"
描述:
在构建过程中,我的Next.js项目遇到了一个问题.本地构建和部署服务器期间的日志(log)如下所示.
Local Build Logs:个
$ next build
▲ Next.js 14.1.0
Creating an optimized production build ...
✓ Compiled successfully
✓ Linting and checking validity of types
✓ Collecting page data
✓ Generating static pages (5/5)
✓ Collecting build traces
✓ Finalizing page optimization
Route (app) Size First Load JS
┌ ○ / 76.3 kB 160 kB
└ ○ /_not-found 882 B 85.1 kB
+ First Load JS shared by all 84.2 kB
├ chunks/69-28f79be715c06873.js 28.9 kB
├ chunks/fd9d1056-f6b668df0b3d2561.js 53.4 kB
└ other shared chunks (total) 1.96 kB
○ (Static) prerendered as static content
以上输出表明构建在本地是成功的.
Deployment Server Error:个
Run (npm run build)
shell: /usr/bin/bash -e ***0***
> personal-portfolio@0.1.0 build
> next build
sh: 1: next: not found
Error: Process completed with exit code 127.
在部署服务器上,我遇到了一个无法识别next的问题.生成失败,退出代码为127
Things I've Tried:个
- 已删除 node 模块、清除NPM缓存并重新安装->;npm i
- 已删除Next并重新安装->;NPM I Next
- 添加了跨环境->;NPM I跨环境
- 添加依赖-"dev":"cross-env NODE_OPTIONS ='--inspect' next dev"
Package.json:
{
"name": "personal-portfolio",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@tabler/icons-react": "^2.47.0",
"@tsparticles/engine": "^3.2.1",
"@tsparticles/react": "^3.0.0",
"@tsparticles/slim": "^3.2.1",
"classnames": "^2.5.1",
"clsx": "^2.1.0",
"cross-env": "^7.0.3",
"framer-motion": "^11.0.5",
"next": "^14.1.0",
"react": "^18",
"react-dom": "^18",
"react-element-to-jsx-string": "^15.0.0",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.0.1",
"react-player": "^2.14.1",
"sonner": "^1.4.0",
"tailwind-merge": "^2.2.1",
"tsparticles-engine": "^2.12.0"
},
"devDependencies": {
"@types/node": "20.11.18",
"@types/react": "18.2.55",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
}
}
对解决这一问题的任何见解或指导都将不胜感激.谢谢!