Next.js Discord

Discord Forum

Next-auth error when using monorepo - Cannot find module '/monorepo/node_modules/next/headers'

Unanswered
Ivory Gull posted this in #help-forum
Open in Discord
Avatar
Ivory GullOP
Cannot find module '/monorepo/node_modules/next/headers' imported from /monorepo/node_modules/next-auth/lib/index.js
Did you mean to import next/headers.js?



Hey! I'm having a weird issue with my monorepo set up and I can't figure out why this import isn't working.

Does anyone have any ideas why this error might be happening?

packages.json
{
  "name": "@repo/next-auth",
  "version": "1.0.0",
  "description": "next auth",
  "type": "module",
  "exports": {
    ".": "./src/index.ts"
  },
  "dependencies": {
    "@auth/prisma-adapter": "^1.3.3",
    "@repo/auth": "*",
    "@repo/db": "*",
    "@repo/email": "*",
    "next": "14.0.4",
    "next-auth": "^5.0.0-beta.9",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@repo/ts-config": "*",
    "eslint": "^8.56.0",
    "nodemailer": "^6.9.9",
    "prettier": "^3.1.1",
    "typescript": "^5.3.3"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

1 Reply

Avatar
Ivory GullOP
For those who care it appeard to be an issue with npm. I switched over to pnpm and everything is fine now.