-
Notifications
You must be signed in to change notification settings - Fork 138
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
Image optimization fails due to version mismatch #406
Comments
I think the current solution is the best we can do without overcomplicating things, and to me having two different versions in We cannot just use The other solutions could be to use |
@Seanw265 thanks for the investigation, you have a good point... but to add to what @conico974 said: To be safe, you should use |
@conico974 @khuezy thanks for your response.
Please correct me if I'm wrong, but I believe this issue would still have occurred even if I had used But I can certainly understand where you're coming from. Without delving in too deep, our deployment process is set up in such a way that we would catch a breaking change before it's released, but I think we're the exception and not the rule. As more projects adopt OpenNext and as Vercel releases new breaking changes to Nextjs that need to be addressed with plugins, this could become a larger issue. Perhaps a low-effort solution would be to add something to the documentation that specifies that the Going a step further, OpenNext could log a warning during the build step if the app's |
Yea, that wouldn't have prevented the issue, but it'll minimize packages that have breaking changes in the |
@Seanw265 I tried to update it to nextjs 14.1. but still getting "Cannot read properties of undefined (reading '0')" |
@kelvinCJJ Are you using windows ? |
Yes I am using windows and downloaded WSL, but it still doesnt seem to work |
@kelvinCJJ What version of next is inside package.json ? ( With ^ or ~ if they're here ) |
Not sure of the actual issue, but downgrading to [email protected] solved it for me |
@kelvinCJJ That's not really a fix, if you see this error it very likely means that the plugin system used internally don't work. |
I am using nextjs ^14.1.0 on windows. I have installed WSL and currently only use sst dev and sst deploy in my cli. How do I run open-next build from within WSL? |
@kelvinCJJ I realize i forgot to ask you this, but which version of OpenNext are you using ? If you didn't change the buildCommand in the sst constructs But you missed one very important point here, you should pin your version of next in package.json ( i.e. no ^ and no ~ and run install again ) And if you want to check if the plugin system is running fine, run |
I am using 2.3.9. I already have wsl installed and deployed as per normal without any changes in the build command. This should mean I am running it in WSL yeah? Update: |
@kelvinCJJ If that's the only output you get, then it's broken. This is what you're supposed to have
My advice, just use github actions |
@kelvinCJJ and anyone else who experiences this issue: I'm simplifying things a bit, but this should cover most cases. You have two options. Option 1You may "pin" the For example: Option 2If you must continue to use For example: AfterwardsAfter adjusting your package.json file, you should consider performing a clean install of all of your dependencies. |
I'm using OpenNext (v2.3.7) through the SST
NextJsSite
construct.I recently had an issue where images loaded through the
<Image>
tag failed at the optimization step. After digging into the issue, I learned that Next changed the optimizer call signature in v14.1.1, hence #374 and #377. I was running v14.2.2.Digging in further, I learned that the OpenNext image optimization plugin was not applied during my build step. This is because the plugin is gated behind a version check for v14.1.1. BUT when a Next version isn't specified in the initial options, OpenNext attempts to extract it from package.json.
However, the version specified in
package.json
is not necessarily the version that's installed. In my case, I had"next": "^14.0.4"
in mypackage.json
, but the actual installed version was v14.2.2. This resulted in a logic mismatch between versions, and the image optimizer function simply returnedCannot read properties of undefined (reading '0')
every time it was invoked.It seems like an appropriate solution would be to instead obtain the installed version number from
package-lock.json
or the module itself, but I defer to the original authors.ETA: I was able to fix my original issue by bumping the
next
version inpackage.json
to^14.2.2
.The text was updated successfully, but these errors were encountered: