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 create next-app fails when directory is a workspace #32713

Closed
karbica opened this issue Dec 21, 2021 · 5 comments · Fixed by #33006
Closed

yarn create next-app fails when directory is a workspace #32713

karbica opened this issue Dec 21, 2021 · 5 comments · Fixed by #33006
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@karbica
Copy link

karbica commented Dec 21, 2021

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

16.13.1

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

next export

Describe the Bug

With the following project structure:

.
├── node_modules
├── package.json
├── sites # this is a workspace
└── yarn.lock

And with the following package.json:

{
  "name": "workspace-test",
  "version": "1.0.0",
  "private": true,
  "license": "MIT",
  "workspaces": [
    "sites/*"
  ]
}

Running this command fails:

yarn create next-app sites/hello-world

With this following output:

yarn create v1.22.17
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
success Installed "create-next-app@12.0.7" with binaries:
      - create-next-app
[##] 2/2Creating a new Next.js app in /Users/karbi/dev/workspace-test/sites/hello-world.

Using yarn.

Installing dependencies:
- react
- react-dom
- next

yarn add v1.22.17
warning Missing version in workspace at "/Users/karbi/dev/workspace-test/sites/asd", ignoring.
warning Missing version in workspace at "/Users/karbi/dev/workspace-test/sites/hello-world", ignoring.
error An unexpected error occurred: "Cannot read properties of undefined (reading 'manifest')".
info If you think this is a bug, please open a bug report with the information provided in "/Users/karbi/dev/workspace-test/sites/hello-world/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Expected Behavior

I would expect that following command would produce a successful boilerplate without error:

yarn create next-app sites/hello-world

Additionally, running the following command works successfully when not targeting a workspace:

yarn create next-app hello-world

To note, using npx works successfully:

npx create-next-app sites/hello-world

To Reproduce

Clone this repository and run the following command in the project root:

yarn create next-app sites/hello-world

Screen Shot 2021-12-21 at 1 20 09 PM

@karbica karbica added the bug Issue was opened via the bug report template. label Dec 21, 2021
@karbica karbica changed the title yarn create next-app errors when directory is a workspace yarn create next-app fails when directory is a workspace Dec 21, 2021
@SergeyMell

This comment has been minimized.

@TheMissouri
Copy link

TheMissouri commented Dec 24, 2021

The problem is when you install dependencies in "hello-world" , the package json created in this folder has not the version attribute

In the souce code :

const packageJson = {
     name: appName,
     private: true,
     scripts: {
       dev: 'next dev',
       build: 'next build',
       start: 'next start',
       lint: 'next lint',
     },

so there is two solution , either specify version in this object or try to know if there is nested folder and should add version in the package json
is there a problem to add a random version like 0.0.1 in all project ?

@karbica
Copy link
Author

karbica commented Dec 24, 2021

@MISSOURI10101
Yep, removing the version number seems to be causing the issue. Also, the version field was present in v12.0.1 but was removed in v12.0.2.

Here is a related issue to workspaces not having their dependencies installed if their version is omitted. It was fixed in yarn@v2 but still broken for yarn@v1.

I believe version should be placed back into the packageJson object with a 0.0.0 (or 0.1.0, as npx does) value for backwards compatibility. And if the developer wants to omit it, then they are free to do so.

Also to note, I now see the reason why npx works is because it defaults with 0.1.0 as the version in the package.json upon app creation.

@John-Dennehy
Copy link

John-Dennehy commented Jan 4, 2022

Just ran into this exact issue. npx version worked. Needed to manually remove node_modules the npm lockfile and add the version to the package.json etc

Would love it if yarn would work as expected

@balazsorban44 balazsorban44 added create-next-app Related to our CLI tool for quickly starting a new Next.js application. kind: bug and removed bug Issue was opened via the bug report template. labels Jan 12, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2022

This closed issue has been automatically locked because it had no new activity for a month. 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 Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants