Next.js14在Nodejs20中构建时显示错误,它在本地主机中运行良好,但在构建时显示错误,部署后显示500内部服务器错误

mzillmmw  于 2023-11-18  发布在  其他
关注(0)|答案(1)|浏览(139)

我刚刚更新了Node.js版本到最新的版本,即版本20,之后我创建了一个next.js最新的项目。它在我的本地主机上运行良好,但在构建时显示错误,我没有更改任何代码或任何东西,我只是创建了一个新的next.js应用程序。如何解决这个问题,我想构建这个项目,并希望在gcloud上部署,有一次我试图部署,但它显示500内部服务器错误。

C:\Users\Lenovo\OneDrive\Desktop>npx create-next-app@latest radha
√ Would you like to use TypeScript? ... No / Yes
√ Would you like to use ESLint? ... No / Yes
√ Would you like to use Tailwind CSS? ... No / Yes
√ Would you like to use `src/` directory? ... No / Yes
√ Would you like to use App Router? (recommended) ... No / Yes
√ Would you like to customize the default import alias (@/*)? ... No / Yes
√ What import alias would you like configured? ... @/*
Creating a new Next.js app in C:\Users\Lenovo\OneDrive\Desktop\radha.

Using npm.

Initializing project with template: app-tw

Installing dependencies:
- react
- react-dom
- next

Installing devDependencies:
- autoprefixer
- postcss
- tailwindcss
- eslint
- eslint-config-next

added 322 packages, and audited 323 packages in 58s

116 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Initialized a git repository.

Success! Created radha at C:\Users\Lenovo\OneDrive\Desktop\radha

C:\Users\Lenovo\OneDrive\Desktop>cd radha

C:\Users\Lenovo\OneDrive\Desktop\radha>yarn
yarn install v1.22.19
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "eslint-config-next > @typescript-eslint/parser > @typescript-eslint/typescript-estree > [email protected]" has unmet peer dependency "typescript@>=4.2.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 60.13s.

C:\Users\Lenovo\OneDrive\Desktop\radha>next build
- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
unhandledRejection Error: Cannot find module 'next/dist/shared/lib/html-context.js'
Require stack:
- C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\pages\_document.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\server\require.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\server\load-components.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\build\utils.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\build\worker.js
- C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\compiled\jest-worker\processChild.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at C:\Users\Lenovo\AppData\Roaming\npm\node_modules\next\dist\server\require-hook.js:110:36
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at 8743 (C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\pages\_document.js:39:18)
    at __webpack_require__ (C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\webpack-runtime.js:25:42)
    at 3262 (C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\chunks\262.js:45:22)
    at __webpack_require__ (C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\webpack-runtime.js:25:42)
    at __webpack_exec__ (C:\Users\Lenovo\OneDrive\Desktop\radha\.next\server\pages\_document.js:63:39) {
  type: 'Error',
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\Lenovo\\OneDrive\\Desktop\\radha\\.next\\server\\pages\\_document.js',
    'C:\\Users\\Lenovo\\AppData\\Roaming\\npm\\node_modules\\next\\dist\\server\\require.js',
    'C:\\Users\\Lenovo\\AppData\\Roaming\\npm\\node_modules\\next\\dist\\server\\load-components.js',
    'C:\\Users\\Lenovo\\AppData\\Roaming\\npm\\node_modules\\next\\dist\\build\\utils.js',
    'C:\\Users\\Lenovo\\AppData\\Roaming\\npm\\node_modules\\next\\dist\\build\\worker.js',
    'C:\\Users\\Lenovo\\AppData\\Roaming\\npm\\node_modules\\next\\dist\\compiled\\jest-worker\\processChild.js'
  ]
}
- info Collecting page data .`

字符串

im9ewurl

im9ewurl1#

像这样更新你的.eslintrc.json文件。

{
  "extends": ["next/babel", "next/core-web-vitals"]
}

字符串

相关问题