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

问题描述 投票:0回答:1

我刚刚将 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 .`
node.js next.js build gcloud updates
1个回答
0
投票

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

{
  "extends": ["next/babel", "next/core-web-vitals"]
}
© www.soinside.com 2019 - 2024. All rights reserved.