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

Doing major changes in a published module can break Nuxt due to caching #7838

Closed
rchl opened this issue Aug 3, 2020 · 4 comments
Closed

Comments

@rchl
Copy link

rchl commented Aug 3, 2020

Versions

  • nuxt: v2.13.3
  • node: v12

Reproduction

On major changes to npm dependencies (seen with Nuxt modules at least), Nuxt can break in a way that will make it error out on start.

Steps to reproduce

  1. Have Nuxt running happily with the current version of modules.
  2. Update some Nuxt module dependency that has made major changes to its structure.

What is Expected?

Nuxt to run

What is actually happening?

Getting an error like:

 FATAL  Template src not found: /Users/me/project/node_modules/@nuxtjs/sentry/lib/sentry.client.js

  at ModuleContainer.addTemplate (node_modules/@nuxt/core/dist/core.js:72:13)
  at ModuleContainer.addPlugin (node_modules/@nuxt/core/dist/core.js:92:26)
  at ModuleContainer.SentryModule (node_modules/@nuxtjs/sentry/lib/module.js:102:10)
  at ModuleContainer.addModule (node_modules/@nuxt/core/dist/core.js:229:34)
  at node_modules/@nuxt/utils/dist/utils.js:1821:43
  at async ModuleContainer.ready (node_modules/@nuxt/core/dist/core.js:49:5)
  at async Nuxt._init (node_modules/@nuxt/core/dist/core.js:699:5)


   ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                                       │
   │   ✖ Nuxt Fatal Error                                                                                  │
   │                                                                                                       │
   │   Error: Template src not found: /Users/me/project/node_modules/@nuxtjs/sentry/lib/sentry.client.js   │
   │                                                                                                       │
   ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯
@rchl rchl added the bug-report label Aug 3, 2020
@rchl
Copy link
Author

rchl commented Aug 3, 2020

This issue is related to the esm caching.

Running ESM_DISABLE_CACHE=true nuxt dev fixes the issue (and makes the stale cache go away).

Note: I've noticed that esm caches code alongside the package, within node_modules/[package]/node_modules/.cache/esm so there is no central place where its cache is stored.

@pimlie @pi0 @clarkdo

@rchl rchl changed the title Doing major changes in a published module can breaks Nuxt due to caching Doing major changes in a published module can break Nuxt due to caching Aug 3, 2020
@rchl
Copy link
Author

rchl commented Aug 3, 2020

I've reproduced this issue with npm. See https://github.com/rchl/nuxt-esm-cache-bug for steps.
It's the esm cache in node_modules/@nuxt/core/node_modules/.cache/esm that breaks this case.

Interestingly, I couldn't reproduce when using yarn but I wonder if it's just a coincidence as with yarn, the node_modules/@nuxt/core/node_modules/ contains some unhoisted modules (unlike with npm) so I wonder if yarn just cleans the whole directory by-accident on installing latest dependency. Or maybe yarn always cleans all "unexpected" directories on changing dependencies.

EDIT: Actually yarn seems to be doing a cleanup of all "unexpected" directories within nuxt_modules on installing.

@pi0 pi0 mentioned this issue Aug 4, 2020
@pi0
Copy link
Member

pi0 commented Aug 4, 2020

Should be fixed with v2.14.1

@rchl
Copy link
Author

rchl commented Aug 4, 2020

Thanks @clarkdo 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants