我无法构建我的项目,它是一个带有NextJS的React,带有中间件,只是一个前端消耗后端。
这是我的package.json
{
"name": "xxxx",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"format": "prettier --write \"{components,app,service,api-generator}/**/*.{js,ts,tsx,d.ts}\"",
"lint": "next lint"
},
"dependencies": {
"@react-google-maps/api": "^2.19.2",
"@types/node": "20.3.1",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"chart.js": "4.2.1",
"next": "13.5.6",
"next-auth": "^4.24.4",
"primeflex": "^3.3.1",
"primeicons": "^6.0.1",
"primereact": "^9.6.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.10.1",
"typescript": "5.1.3"
},
"devDependencies": {
"eslint": "8.43.0",
"eslint-config-next": "13.4.6",
"prettier": "^2.8.8",
"sass": "^1.63.4"
}
}
字符串
当我尝试构建时的错误:
Failed to compile.
./node_modules/@babel/runtime/regenerator/index.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/@babel/runtime/regenerator/index.js
./node_modules/next-auth/react/index.js
> Build failed because of webpack errors
Creating an optimized production build .
型
我不知道该怎么办,有人能帮忙吗?
1条答案
按热度按时间bis0qfac1#
问题是在我的midware.ts文件,当我得到的会话,以确定是否有一些用户登录,所以我可以重定向它或没有.为了解决我这样做:
字符串
使用getSession方法构建总是失败,所以将其更改为getToken,构建工作正常。