Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

create-next-app is currently somewhat incompatible with yarn 2 #30198

Closed
sicarius97 opened this issue Oct 23, 2021 · 1 comment · Fixed by #30936
Closed

create-next-app is currently somewhat incompatible with yarn 2 #30198

sicarius97 opened this issue Oct 23, 2021 · 1 comment · Fixed by #30936
Labels
bug Issue was opened via the bug report template.

Comments

@sicarius97
Copy link
Contributor

What version of Next.js are you using?

11.1.0

What version of Node.js are you using?

14.17.6

What browser are you using?

Chrome

What operating system are you using?

Windows, Ubuntu

How are you deploying your application?

Vercel, but doesnt matter

Describe the Bug

Background

Yarn is often used with nextjs projects and yarn has now just about fully transitioned to preferring yarn 2 rather than yarn classic. More and more yarn classic features are being deprecated, and as such, I think it would be important for yarn 2 to be even more compatible with nextjs.

Currently, one of the pieces that is not super compatible is scaffolding an initial nextjs application using create-next-app. The current convention when using yarn to scaffold a new project is to use the yarn create next-app command. However, this will likely soon be deprecated in preference of using yarn's new cli command, yarn dlx create-next-app. Switching to using this instead of yarn create would be not only a better long term convention, but it would also make it so that a specific yarn classic package for supporting yarn create would no longer be necessary. This almost works, but not quite as for reasons stated below.

Issue

Using yarn dlx first requires a project to initialize yarn to use yarn 2 by running the command yarn set version berry, which creates 2 or 3 files depending on the OS including a .yarnrc.yml, package.json, and the .yarn directory with the subdirectory releases, which contains the current yarn release to be used with the project. If one then attempts to use yarn dlx create-next-app, it will fail with an exit code of 1 due to possibly conflicting files, particularly all 3 of the above mentioned files. The only workaround to this currently is to delete the package.json that it creates and then proceed to save the project in its own subdirectory of that yarn project, and then copy all of the files of that subdirectory that is created and hoist them into the parent directory. This isn't super conducive as I know many people like myself often create a project directory first and want to scaffold the project in that particular directory.

Expected Behavior

The expected behaviour would be for yarn dlx create-next-app ., much like yarn dlx create-react-app ., to either recognize the use of yarn 2 and ignore certain directory/file patterns in order to successfully scaffold an app or somehow otherwise be more compatible with yarn 2's yarn dlx equivalent of npx. Specifically this can probably be accomplished by ignoring the existence of .yarn/releases .yarnrc.yml and by either overwriting the package.json or adding to it.

To Reproduce

Update yarn to any 1.22.X version compatible with yarn 2, create a project directory and enter it, run yarn set version berry in terminal, and then run yarn dlx create-next-app .. It will most likely exit with an error code due to possible file conflicts.

@sicarius97 sicarius97 added the bug Issue was opened via the bug report template. label Oct 23, 2021
@sicarius97
Copy link
Contributor Author

Opened pull request #30936 as a proposed solution for this issue.

@vercel vercel locked and limited conversation to collaborators Jan 15, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #33339 Jan 15, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants