New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime #13430
Comments
and i try to use unstable_allowDynamic and it does not work.
|
We've never tested with nextjs edge runtime, so we're not entirely sure. However, |
thanks for your reply, i will try to ask nextjs for help |
one question.why nextjs will build borwser.umd.js. I'm importing it the wrong way? |
I don't know enough about how nextjs' compiler works to answer. Maybe it just compiles all files, or maybe Next edge runtime imports browser build? But you shouldn't be running browser.umd.js unless you're importing Mongoose on frontend. |
I took a look and you currently can't use Mongoose to connect to MongoDB in NextJS edge runtime because NextJS edge runtime doesn't allow using native node APIs, including Furthermore, it looks like whatever the build process NextJS edge runtime uses pulls the "browser" version of every npm package based on the We will add docs for this. |
docs: add nextjs page with link to next starter app and couple FAQs
Prerequisites
Mongoose version
7.2.0
Node.js version
18.x
MongoDB version
5/x
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
13
Issue
when i use mongoose in nextjs edge runtime meet this error
./node_modules/_mongoose@7.2.0@mongoose/dist/browser.umd.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
Import trace for requested module:
./node_modules/_mongoose@7.2.0@mongoose/dist/browser.umd.js
./lib/dbConnect.ts
./lib/completion.ts
does mongoose support nextjs edge runtime?
api/get.ts
dbconnect.ts
HOW can i resolve it.
The text was updated successfully, but these errors were encountered: