7

Faced this issue when I was using login functionality developed by my teammate in a group project and apparently I am the only one facing this issue.

npm version: 8.19.3 node version: 16.17.0

package.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 - Error: Cannot find module 'next/headers'

I have tried deleting the node_modules and .next folders but I am still facing this issue.

3
  • 1
    I think it is a version mismatch Commented Nov 6, 2022 at 21:58
  • Yes changing next-auth to 4.15.0, fixes this issue. Commented Nov 6, 2022 at 22:52
  • Yes, that's the issue, anyway they should pass the experimental process. Commented Nov 7, 2022 at 2:16

1 Answer 1

6

That is when you update Nextjs to version 13 with next-auth, which is intended for next@13 users, in your case using version 12 yet, the root cause the error in v4.12.x with next/headers package from next@12, so it could be to support getting the session in React Server Components for example.

Edit package.json, it should fix your issue:

{
  "next-auth": "4.15.1"
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.