簡體   English   中英

Next dev 成功運行,但繼續在瀏覽器上加載

[英]Next dev successfully runs, but keeps loading on browser

運行yarn dev始終成功運行,如我的 vs code 終端所示:

$ yarn dev
yarn run v1.22.19
warning ..\..\..\..\package.json: No license field
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
info  - Loaded env from C:\Users\Jesti\OneDrive\Desktop\projects\vallendra-portfolio\.env.local
event - compiled client and server successfully in 5.1s (540 modules)
wait  - compiling / (client and server)...
event - compiled client and server successfully in 1963 ms (548 modules)
wait  - compiling...
event - compiled client and server successfully in 1913 ms (540 modules)

每當有代碼更改時,它甚至都能成功重新編譯,但不知何故,當我嘗試訪問localhost:3000時,瀏覽器始終處於這種無休止的加載狀態 state。

這是我的依賴項列表:

"dependencies": {
    "@giscus/react": "^2.2.6",
    "@material-tailwind/react": "^1.2.5",
    "@vercel/og": "^0.0.27",
    "mongoose": "^6.8.4",
    "next": "^13.1.5",
    "next-cloudinary": "^1.11.0",
    "next-themes": "^0.2.1",
    "nextjs-progressbar": "^0.0.16",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^4.6.0",
    "swr": "^2.0.1"
  },
  "devDependencies": {
    "@tailwindcss/line-clamp": "^0.4.2",
    "@types/node": "18.11.18",
    "@types/react": "^18.0.17",
    "@types/react-dom": "^18.0.6",
    "autoprefixer": "^10.4.12",
    "postcss": "^8.4.18",
    "prettier": "^2.8.3",
    "prettier-plugin-tailwindcss": "^0.2.1",
    "tailwind-scrollbar": "^2.0.1",
    "tailwindcss": "^3.1.8",
    "typescript": "^4.6.4"
  }

我嘗試重新啟動瀏覽器和 PC。

我嘗試重新安裝所有依賴項,甚至嘗試降級到next 12.3.0 ,因為我在我的package.json中使用了next 13.1.5

我嘗試多次刪除 the.next 文件夾。 這些都沒有用。

yarn buildyarn start看起來不錯。 非常感謝有關此問題的任何幫助,謝謝。

事實證明,問題不在於依賴項、一些隨機的 next.js 錯誤或瀏覽器。

這是我關於 mongoose/mongodb 的代碼。 在我的一個 server side.ts 文件中,代碼的某個部分包含對 mongodb 的查詢,我忘記建立與數據庫的連接,因此服務器有點掛起(這只是我的猜測)。

在我在那部分添加檢查連接的代碼后,開發服務器再次正常運行。

如果您已經嘗試了其他人提供的解決方案,但仍然無效。 您最近在代碼中執行的某些操作可能會阻塞服務器線程。

那是我的問題,它可能也是你的。

嘗試使用 npm 並使用以下 npm 命令

npm run dev

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM