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

unhandledRejection: Error: Cannot find module 'lru-cache' #65674

Closed
champ6803 opened this issue May 13, 2024 · 5 comments
Closed

unhandledRejection: Error: Cannot find module 'lru-cache' #65674

champ6803 opened this issue May 13, 2024 · 5 comments
Labels
bug Issue was opened via the bug report template. Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. locked

Comments

@champ6803
Copy link

champ6803 commented May 13, 2024

To Reproduce

  1. npm run dev
  2. error - unhandledRejection: Error: Cannot find module 'lru-cache'

Current vs. Expected behavior

I used to be able to use a library called "lru-cache" in my projects, but one day I couldn't use lru-cache. I would like to know if nextjs has removed this library and if it has been removed, should it be announced or not?

Provide environment information

Operating System:
    Platform: win32
    Arch: x64
    Version: Windows 11 Enterprise
Binaries:
    Node: 20.12.2
    npm: N/A
    Yarn: N/A
    pnpm: N/A
Relevant packages:
    next: 12.3.4
    eslint-config-next: 11.0.1
    react: 17.0.2
    react-dom: 17.0.2

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

Not sure, Developer Experience, Documentation

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

next dev (local), next start (local)

Additional context

I have to remove code related to "lru-cache" to be able to run the project. I would like to know how to fix this.

@champ6803 champ6803 added the bug Issue was opened via the bug report template. label May 13, 2024
@github-actions github-actions bot added Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. labels May 13, 2024
@champ6803 champ6803 reopened this May 13, 2024
@icyJoseph
Copy link
Contributor

Do you mean that you used it without having it installed, aka in your package.json? If so, then just install it yourself, I see in the examples, an app that uses lru-cache, https://github.com/vercel/next.js/blob/fedb675520e0de8f360f8d2e262acdf76b4f0491/examples/api-routes-rate-limit/package.json, you should use it as such.

I reckon that you got impacted by vendor-ing of the package. Next.js still has it, but as a compiled dependency, so that we, the users, don't need to download and reinstall it every time. However, that belongs to the internals of the framework, and you should not rely on that. Install the package on your project, and take it from there.

@champ6803
Copy link
Author

champ6803 commented May 13, 2024

Do you mean that you used it without having it installed, aka in your package.json? If so, then just install it yourself, I see in the examples, an app that uses lru-cache, https://github.com/vercel/next.js/blob/fedb675520e0de8f360f8d2e262acdf76b4f0491/examples/api-routes-rate-limit/package.json, you should use it as such.

I reckon that you got impacted by vendor-ing of the package. Next.js still has it, but as a compiled dependency, so that we, the users, don't need to download and reinstall it every time. However, that belongs to the internals of the framework, and you should not rely on that. Install the package on your project, and take it from there.

Nextjs has an announcement space? Is there anything about update dependencies? If so, where should I follow them?

@icyJoseph
Copy link
Contributor

I think, from a project point of view, you are over stepping your boundaries, if you want to rely on a transient dependency like that. Such packages are never part of the project's public API, and because of that, it is your sole responsibility to deal with the consequences of having done so.

@ztanner
Copy link
Member

ztanner commented May 13, 2024

Hi -- if your project depends on lru-cache, you should install it in your project. Next.js uses it internally, but as @icyJoseph mentioned, you should not rely on Next.js providing it. We have not removed this dependency from our internal usage, and without a link to a reproduction, we're not able to help debug further.

@ztanner ztanner closed this as not planned Won't fix, can't repro, duplicate, stale May 13, 2024
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 May 28, 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. Developer Experience Issues related to Next.js logs, Error overlay, etc. Documentation Related to Next.js' official documentation. locked
Projects
None yet
Development

No branches or pull requests

3 participants