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

Yarn 2 Dependency Issues #11652

Closed
Js-Brecht opened this issue Apr 4, 2020 · 6 comments · Fixed by #11684
Closed

Yarn 2 Dependency Issues #11652

Js-Brecht opened this issue Apr 4, 2020 · 6 comments · Fixed by #11684

Comments

@Js-Brecht
Copy link

Bug report

Describe the bug

There seems to be some dependency issues with v9.3.4 when using Yarn 2. First one I ran into seems to be here:
https://github.com/zeit/next.js/blob/7f8f149f9986afd8cb916e27eb231bacaad9dc9d/packages/next/build/utils.ts#L6
I was able to work around it by unplugging next, and changing that to next/dist/compiled/strip-ansi.

But then I started hitting other roadblocks. For example, autodll-webpack-plugin is using find-cache-dir (which I noticed is listed as an external), but it is not listed as a dependency for that package. As a matter of fact, its package.json appears to be quite minimal. It looks to me to be a product of the your build process? I'll be honest: I didn't take much time to analyze it. I thought you guys would be better equipped to deal with this.

To Reproduce

Expected behavior

It should start the dev server

System information

  • OS: Linux
  • Browser (if applies): Chrome
  • Version of Next.js: v9.3.4

Additional context

v9.3.3 works fine 🤷‍♂️

@timneutkens
Copy link
Member

#11684

@paulbjensen
Copy link

Just to add context, I updated an app to 9.3.4, ran npm run build on it, and ran into this:

./node_modules/next/dist/client/next.js
Error: Cannot find module 'find-cache-dir'
Require stack:

I installed 'find-cache-dir' in my app's dependencies, and that resolved it.

@Js-Brecht
Copy link
Author

@paulbjensen that is a workaround, yes, but in that case, those dependencies should really be listed as peerDependencies. It seems odd to me, though, that next would require you to install all of these packages that it needs, but I don't.

This is what I'm encountering with yarn 2:

Error: next tried to access find-cache-dir, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: find-cache-dir (via "find-cache-dir")
Required by: next@virtual:308db880e6f62e891e71e5b37d20b8a6feac82b6cea97f7dd3c4e797732ec4f2e5079f0015b3ee4f816e93407bdd47bda6f8ae264b19ca8bd9ef518f288df055#npm:9.3.4 (via /D:/dev/source/next/nextjs-yarn2-issue/.yarn/unplugged/next-virtual-c89c8a1136/node_modules/next/dist/compiled/autodll-webpack-plugin/)

Okay, I fix that, and I get:

Error: next tried to access mkdirp, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: mkdirp (via "mkdirp")
Required by: next@virtual:308db880e6f62e891e71e5b37d20b8a6feac82b6cea97f7dd3c4e797732ec4f2e5079f0015b3ee4f816e93407bdd47bda6f8ae264b19ca8bd9ef518f288df055#npm:9.3.4 (via /D:/dev/source/next/nextjs-yarn2-issue/.yarn/unplugged/next-virtual-c89c8a1136/node_modules/next/dist/compiled/babel-loader/)

Okay, install mkdirp, and I get

[ error ] ./.yarn/unplugged/next-virtual-c89c8a1136/node_modules/next/dist/client/next-dev.js
TypeError: invalid options argument
    at new Promise (<anonymous>)
    at Generator.throw (<anonymous>)

So now I have to go dig through babel-loader's dependencies, and I find out that babel-loader depends on [email protected], not mkdirp@latest, since mkdirp was replaced by make-dir (a whole 14 days ago 🤷‍♂).

@timneutkens is there a particular reason why next is requiring the end-user to handle next's dependencies?

@timneutkens
Copy link
Member

This has been fixed already today:

@Js-Brecht
Copy link
Author

Ah, missed the last two PRs. Thanks!

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants