Skip to content
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

Getting "Cannot find module 'next/headers' or its corresponding type declarations" error while trying to deploy to vercel. #62478

Closed
mayank1513 opened this issue Feb 24, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js.

Comments

@mayank1513
Copy link
Contributor

Link to the code that reproduces this issue

https://github.com/mayank1513/nextjs-themes-ultralight

To Reproduce

  1. fork the repo and deploy to Vercel.

Current vs. Expected behavior

All the examples build and work very well locally and on GitHub code spaces. However, when trying to deploy to Vercel, it fails and shows the following error.

../../lib/nthul/src/server/server-target/server-target.tsx:2:25
Type error: Cannot find module 'next/headers' or its corresponding type declarations.

Expected behavior: The app should build and deploy normally on Vercel.

Provide environment information

Vercel

Tested with node 16, 18 and 20. Fails on all.

Which area(s) are affected? (Select all that apply)

Package manager (npm, pnpm, Yarn), Turbopack (--turbo), TypeScript (plugin, built-in types)

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

No response

@mayank1513 mayank1513 added the bug Issue was opened via the bug report template. label Feb 24, 2024
@github-actions github-actions bot added Turbopack Related to Turbopack with Next.js. TypeScript Related to types with Next.js. labels Feb 24, 2024
@balazsorban44 balazsorban44 removed the Turbopack Related to Turbopack with Next.js. label Feb 27, 2024
@balazsorban44
Copy link
Member

https://github.com/mayank1513/nextjs-themes-ultralight/blob/24b3f05ede31c0444727af77cb6d73b829eb4f82/lib/nthul/package.json#L47-L56 looks like next is only added as an optional peer dependency. So it's likely not installed and such the import will fail.

You likely want to add it as a dev dependency for build to succeed.

(Note: the project did not use Turbopack, but Turborepo, which are different things. See https://turbo.build/)

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants