jihchi / vitejs-template-react-rescript

Integrating ReScript and rescript-react into the official Vite React template

Home Page:https://vitejs-template-react-rescript.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Peer dependency issue

ccavolt opened this issue · comments

Hi, I followed the instructions in the readme (i.e. fresh install) for cloning the project. When I run npm i, I get the following output:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: rescript-vitest@0.2.0
npm ERR! Found: vite@3.0.4
npm ERR! node_modules/vite
npm ERR! dev vite@"^3.0.4" from the root project
npm ERR! peer vite@"^3" from @jihchi/vite-plugin-rescript@4.0.1
npm ERR! node_modules/@jihchi/vite-plugin-rescript
npm ERR! dev @jihchi/vite-plugin-rescript@"^4.0.1" from the root project
npm ERR! 2 more (@vitejs/plugin-react, vitest)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vite@"^2.0.0" from rescript-vitest@0.2.0
npm ERR! node_modules/rescript-vitest
npm ERR! dev rescript-vitest@"^0.2.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: vite@2.9.14
npm ERR! node_modules/vite
npm ERR! peer vite@"^2.0.0" from rescript-vitest@0.2.0
npm ERR! node_modules/rescript-vitest
npm ERR! dev rescript-vitest@"^0.2.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

It looks like the issue is with rescript-vitest (wants an older version of vite than other packages will allow), which hasn't been updated in 6 months, but I wanted to let you know because it appears to break this template. I'm no npm expert, so if there's a workaround for this I'd be glad to hear it.

Could you share results of following commands?

npm -v
node -v
git log -n 1

I use npm@8.5.5 and node@v16.15.0, don't see the same error.

So it appears this issue concerns npm having a bug in <= 8.5.5 where it wasn't actually checking peer dependencies. They fixed it in >= 8.6.0, which broke builds for a lot of people because now you have to add the flag --legacy-peer-deps to get the install to work again. I did this for the versions of npm I'm using (8.15.0 and 8.16.0) and now it works. It's documented in these issues:

Issue 1
Issue 2
Issue 3 (Most succinct)

I've filed this issue with this repo rescript-vitest; hopefully they'll update the vite peer dependency so the flag will no longer be required.

After I upgraded rescript-vitest to 0.3.0, the peer dependency errors no longer exists.