next-learn: Chapter 1: install failed

npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example"

npm resolution error report

While resolving: undefined@undefined Found: react@19.0.0-rc-6230622a1a-20240610 node_modules/react react@“19.0.0-rc-6230622a1a-20240610” from the root project

Could not resolve dependency: peer react@“>= 16” from @heroicons/react@2.1.3 node_modules/@heroicons/react @heroicons/react@“^2.0.18” from the root project

Fix the upstream dependency conflict, or retry this command with --force or --legacy-peer-deps to accept an incorrect (and potentially broken) dependency resolution.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 27
  • Comments: 24 (2 by maintainers)

Most upvoted comments

giveup npx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example"

git clone https://github.com/vercel/next-learn/tree/main cd dashboard/starter-example pnpm i pnpm run dev

@AB-xdev 100%. It’s bad for NextJS to have potential users become frustrated and have a poor experience because of “broken production.” The team at NextJS is very strong, and releasing something half baked shouldn’t happen. I send people here often, and just this week I was going through the tutorial myself, to be blocked at square 0.

cc. @rauchg @delbaoliveira

From last commit 11 jun 2024 Delba de Oliveira changed package.json:

"next": "^14.0.2"               to     "next": "15.0.0-rc.0"
"react": "18.2.0"                to      "react": "19.0.0-rc-6230622a1a-20240610",
"react-dom": "18.2.0"       to       "react-dom": "19.0.0-rc-6230622a1a-20240610"

besides, she changed from npx package manager to pnpm package manager.

So the solution that worked for me was:

  1. Install pnpm from https://pnpm.io/installation (If you are in Windows, after intalling remember to log out and log in again so windows path var gets pnpm to work).

  2. Clone from Github

git clone https://github.com/vercel/next-learn

  1. Update your node version, mine is v22.3.0

  2. In /next-learn/dashboard/starter-example/ edit the file .nvmrc and replace the number to your actual node version.

  3. Finally, in power shell or command shell install it with:

pnpm i

pnpm dev

Sin título

Remember to install it in In /next-learn/dashboard/starter-example/

There you go! Happy learnning 😄

Maybe it would be a great idea - for the future - to not commit release candidate versions to the default branch that is used in production… or at least check if it still works then…

My workaround: Download or checkout commit https://github.com/vercel/next-learn/commit/b7a4366f682163a6643416c9cdf2d9c43d0fc542 which is the commit before it broke.

learn nextjs from error…

Worked for me

cc: QUECOSITA

Alternatively, you can just replace npx from the original command with pnpm dlx, instead of cloning the repo:

pnpm dlx create-next-app@latest nextjs-dashboard --example "https://github.com/vercel/next-learn/tree/main/dashboard/starter-example"

Worked just fine for me, with no warnings whatsoever:

image

You don’t need corepack, but we believe pnpm is a better default so we’ve updated guidance to start here.

I am not sure is it a right way of handling it, but after getting this error during installation, I went to the nextjs-dashboard folder, in the package.json file I changed back dependencies updated in this commit https://github.com/vercel/next-learn/pull/743/files to:

    "next": "^14.0.2",  
    "react": "18.2.0",
    "react-dom": "18.2.0",

And everything worked as expected after that. It is not an ideal solution, but it unblocked me.

PS

Worked for me

3

cc: QUECOSITA

Does using pnpm resolve the issue with importing useActionState hook from react@rc ?

I can run the project as normal after cloning it, but in Chapter 14 of the Learn Next tutorial, it implements this hook which happens to be only available in React Canary and Experimental versions. I get the same error reported in this ticket when trying to update React, React-Dom and Next to the bleeding edge versions just to have access to this hook. Anybody have a workaround?

Getting this error as well. This problem looks to be created from the recent code merged https://github.com/vercel/next-learn/pull/743/files

The problem seems to be a react version mismatch.

The @heroicons/react package expects a react version greater than or equal to version 16, but the latest commit (58f9a68c6a2a0050976e52969b0dcf427281610a) specified an install of react version 19.0.0-rc-6230622a1a-20240610.

According to the semantic versioning documentation, the prerelease candidate tag -rc makes it so that the installed version of react would not satisfy @heroicons/react’s react version requirement of >=16, despite it technically being a more recent version.

npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: undefined@undefined
npm error Found: react@19.0.0-rc-6230622a1a-20240610
npm error node_modules/react
npm error   react@"19.0.0-rc-6230622a1a-20240610" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@">= 16" from @heroicons/react@2.1.3
npm error node_modules/@heroicons/react
npm error   @heroicons/react@"^2.0.18" from the root project

This was just my personal preference, but if you don’t want access to the final-example while learning:

  1. Create/navigate the directory you want to clone into.
  2. Clone the repo but don’t checkout.
git clone --filter=blob:none --no-checkout https://github.com/vercel/next-learn
  1. Navigate to the cloned but empty repo
cd next-learn/
  1. Create a sparse checkout.
git sparse-checkout set --cone
  1. Select the main branch.
git checkout main
  1. Clone just the starter-example directory.
git sparse-checkout set dashboard/starter-example
  1. Rejoin quecosita’s instructions above and update your /dashboard/starter-example/.nvmrc to your current version of node, followed by running pnpm i & pnpm dev

The issue can be resolved by upgrading the Node.js version to 18.17.0 or higher.

I had the same error. Since the project was downloaded, I tried installing the npm packages with yarn, but I encountered the following error.

➜  nextjs-dashboard yarn
yarn install v1.22.19
info No lockfile found.
[1/5] 🔍  Validating package.json...
error @: The engine "node" is incompatible with this module. Expected version ">=18.17.0". Got "18.16.1"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

This made me realize there was an issue with the Node.js version. After changing the Node.js version to 20 and reinstalling, the error no longer occurred.

Additionally, the .nvmrc file in this project should be updated to specify the exact version of Node.js required.