错误是由于在'./src/models/userModel.js'中导入'mongoose/dist/browser.umd.js'引起的

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


Failed to compile.
./src/models/userModel.js
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime 
Learn More: https://nextjs.org/docs/messages/edge-dynamic-code-evaluation
The error was caused by importing 'mongoose/dist/browser.umd.js' in './src/models/userModel.js'.
Import trace for requested module:
  ./src/models/userModel.js
  ./src/auth.js
  ./src/middleware.js
> Build failed because of webpack errors
Error: Command "npm run build" exited with 1

版本- "猫鼬": "^8.3.3", “下一个”:“14.2.3”,

通过 Vercel 部署我的应用程序时,我遇到了此错误。该应用程序在本地主机中运行顺利,但在部署过程中遇到问题。

此应用程序中的技术 - 下一个 14,nextauth,猫鼬

这是我的 github 存储库 - https://github.com/naimursardul/authentication-nextauthjs 您可以轻松查看存储库,因为该应用程序非常小。

我尝试了多种方法来解决这个问题,但都没有效果。

mongoose next.js mongoose-schema next-auth
1个回答
0
投票

我也有同样的问题

Edge 运行时不允许动态代码评估(例如“eval”、“new Function”、“WebAssembly.compile”) 了解更多:https://nextjs.org/docs/messages/edge-dynamic-code-evaluation 该错误是由于在“./lib/db.ts”中导入“mongoose/dist/browser.umd.js”引起的。

© www.soinside.com 2019 - 2024. All rights reserved.