This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
create-next-app is currently somewhat incompatible with yarn 2 #30198
Labels
bug
Issue was opened via the bug report template.
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 supportingyarn 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 commandyarn 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 useyarn 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 likeyarn 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'syarn 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 runyarn dlx create-next-app .
. It will most likely exit with an error code due to possible file conflicts.The text was updated successfully, but these errors were encountered: