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)
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:
besides, she changed from npx package manager to pnpm package manager.
So the solution that worked for me was:
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).
Clone from Github
git clone https://github.com/vercel/next-learn
Update your node version, mine is v22.3.0
In /next-learn/dashboard/starter-example/ edit the file .nvmrc and replace the number to your actual node version.
Finally, in power shell or command shell install it with:
pnpm i
pnpm dev
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…
Alternatively, you can just replace
npxfrom the original command withpnpm 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:
You don’t need corepack, but we believe
pnpmis 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-dashboardfolder, in thepackage.jsonfile I changed back dependencies updated in this commithttps://github.com/vercel/next-learn/pull/743/filesto:And everything worked as expected after that. It is not an ideal solution, but it unblocked me.
PS
Worked for me
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?
The problem seems to be a react version mismatch.
The
@heroicons/reactpackage expects a react version greater than or equal to version 16, but the latest commit (58f9a68c6a2a0050976e52969b0dcf427281610a) specified an install of react version19.0.0-rc-6230622a1a-20240610.According to the semantic versioning documentation, the prerelease candidate tag
-rcmakes 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.This was just my personal preference, but if you don’t want access to the final-example while learning:
pnpm i&pnpm devThe 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.
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.