当我在一个小组项目中使用我的队友开发的登录功能时遇到了这个问题,显然我是唯一一个遇到这个问题的人。
npm版本:8.19.3节点版本:16.17.0
软件包. json:-
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "npm run prettify && next dev",
"build": "npm run prettify && next build",
"start": "next start",
"lint": "npm run prettify && next lint",
"prettify": "prettier --write \"**/*.{js, jsx}\""
},
"dependencies": {
"@emotion/react": "11.10.4",
"@emotion/server": "11.10.0",
"@emotion/styled": "11.10.4",
"@mui/icons-material": "5.10.6",
"@mui/material": "5.10.6",
"@mui/x-date-pickers": "^5.0.3",
"cryptr": "^6.0.3",
"dayjs": "^1.11.5",
"intl": "^1.2.5",
"mui-file-dropzone": "^4.0.2",
"next": "12.2.5",
"next-auth": "^4.12.0",
"normalize.css": "^8.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-share": "^4.4.1",
"react-toastify": "^9.0.8",
"swr": "^1.3.0",
"universal-cookie": "^4.0.4"
},
"devDependencies": {
"eslint": "8.23.1",
"eslint-config-next": "12.3.1",
"eslint-config-prettier": "8.5.0",
"prettier": "2.7.1"
}
}
错误:-
error - Error: Cannot find module 'next/headers'
我已经尝试删除node_modules和.next文件夹,但我仍然面临这个问题。
1条答案
按热度按时间hmmo2u0o1#
这是当您使用
next-auth
将Nextjs更新到版本13时,这是针对next@13用户的。在您使用版本12的情况下,根本原因是在v4.12.x
中使用来自next@12的next/headers包,可能是为了支持在React Server Components中获取会话。编辑package.json,也许它可以解决您的问题: