react-carousel icon indicating copy to clipboard operation
react-carousel copied to clipboard

App throws error on Building with npm run build

Open tnmyd opened this issue 3 years ago • 20 comments

Describe the bug After I build my app which is using react-carousel for production using npm run build, it gives an error when I try to open the page where react-carousel is used. The error screenshots are provided below

Expected behavior To render the page as it appears during development.

Screenshots image

Environment

  • node 14.4.0, npm 6.14.5, react-carousel 2.0.1
  • Desktop Windows 10
  • Edge, Chrome

Please look into this. Its a great library and the best one for my purpose but this error blindsided me.

tnmyd avatar Aug 02 '20 14:08 tnmyd

Hi @DarkHorse1997 Thanks for reporting this issue. Unfortunately, now I don't have time to resolve this issue. If you know how to fix this please submit PR, otherwise, I will work on fixing this on next Friday

RobertHebel avatar Aug 04 '20 06:08 RobertHebel

Hey @RobertHebel I'm having the same error after build with yarn. Also v. 2.0.1 used here.

cnavarro-cafeto avatar Aug 06 '20 19:08 cnavarro-cafeto

is anyone working on this?

sashaslow avatar Sep 20 '20 20:09 sashaslow

I just ran into this issue as well - very unfortunate. One thing that is puzzling me at this point is why, after doing a production build (e.g. with NODE_ENV properly set to production), the Carousel still ends with a dependency on recoil.development.js (as shown in the stack trace). All other dependencies , as expected, are the production dependencies.

Any tips on how to proceed on fixing this - I would be happy to dig in and try to sort it out? This will definitely be getting in the way of moving my app to prod, as it fails when packaged in production mode.

@RobertHebel - any tips on where to start looking at the root cause for this ? The error itself is pretty cryptic and seems like it might be coming from recoil in the first place..

akochnev avatar Sep 23 '20 04:09 akochnev

I can work on this, anywhere to start with?

ishan28mkip avatar Sep 27 '20 01:09 ishan28mkip

I've encountered the same error in all 2.0.0+ versions, regardless of which recoil version I install. I am able to successfully build with this version @brainhubeu/[email protected], but this in turn breaks plugins (an unfortunate trade off).

I first assumed it came from Recoil due to an old dependency of some sorts (see also: https://github.com/facebookexperimental/Recoil/issues/122) but they have fixed that by now and changing the version does not actually solve the issue for this package. Hope this gives some direction, but I'm note so sure myself where this is coming from either.

geo-mathijs avatar Sep 28 '20 19:09 geo-mathijs

@mnelemans - I did try messing around with recoil versions and had similar results.

My other suspicion was the fact that the production build of my app ends up using the development version of recoil (instead of using the prod one). I haven't been able to change that - any ideas why that might be the case ?

akochnev avatar Sep 28 '20 22:09 akochnev

I think I have discovered both issues, with the root cause being a webpack conflict. Please checkout my PR (https://github.com/brainhubeu/react-carousel/pull/646) to see if it solves the issue for you guys as well.

geo-mathijs avatar Sep 29 '20 12:09 geo-mathijs

@mnelemans I tried your change and still I am getting the same build error. To be sure I cloned your repo, ran yarn install, copied the code from react-carousel/lib into my own project.

ishan28mkip avatar Sep 29 '20 12:09 ishan28mkip

Thanks for the heads up, my bad! Seems I had the bumped Recoil in my package.json that imports Carousel. I'll push the bumped version to the PR as well, as that does seem to fix it.

geo-mathijs avatar Sep 29 '20 13:09 geo-mathijs

Thinking about this a bit more, it is probably related to the incorrect development mode setting in the webpack config. Looking at the latest Recoil they stopped using recoil.development.js which is probably why it fixes the issue.

geo-mathijs avatar Sep 29 '20 13:09 geo-mathijs

Please try again with the latest commit (https://github.com/brainhubeu/react-carousel/pull/646/commits/7815c7e3745a4198a71eb7c7648f638236dd45a0) in my PR. It seems bumping recoil to at least ^0.0.11 fixes the read-only issue, while setting webpack to use production mode correctly ensures it reads from the production version.

geo-mathijs avatar Sep 29 '20 13:09 geo-mathijs

@mnelemans Amazing. It works now. The recoil bump was enough to make it work. You might as well bump the recoil version to the latest version 0.0.13, checked it works for that version as well.

ishan28mkip avatar Sep 29 '20 16:09 ishan28mkip

@mnelemans what's the right way to install the latest commit from your PR?

I can't find a way to do that.

cristiangrojas avatar Nov 21 '20 12:11 cristiangrojas

@mnelemans what's the right way to install the latest commit from your PR?

I can't find a way to do that.

I got this working by

  1. Clone @mnelemans 's fork
  2. yarn
  3. yarn build
  4. Copy the contents of react-carousel/lib into my project's node_modules/@brainhubeu/react-carousel/lib folder and overwriting the existing files.

After rebuilding my create-react-app project, everything seems to work.

marpstar avatar Jan 04 '21 15:01 marpstar

@mnelemans and @marpstar this worked beautifully, thank you for the detailed fix!

crbilladeau avatar Jan 10 '21 21:01 crbilladeau

Got it working in development mode using instructions provided by @marpstar. Since node_modules isn't usually checked in, for production is the long-term fix to wait for the PR in #646 to be merged?

sudravi avatar Feb 04 '21 22:02 sudravi

I've got the same issue, but I'm deploying automatically on Vercel. Is there any way to solve this or do we have to wait for PR?

ArmedVeteran avatar Feb 05 '21 02:02 ArmedVeteran

Please merge that PR, this is quite annoying bug

rstefek avatar Apr 07 '21 10:04 rstefek

Indeed! This need to be merged.

danieljaguiar avatar Apr 07 '21 17:04 danieljaguiar